반응형

IT/JSP&javascript&jQuery 24

자바스크립트 - location.href / location.replace()의 차이

location.href / location.replace() 개념적 차이 - location.href 는 프로퍼티 => location.href = 'example.page'; - location.replace() 는 메서드 => location.replace('example.page'); 기능적 차이 - location.href 는 새로운 페이지 이동 후 히스토리에 기록한다. - location.replace() 현재 페이지를 새로운 페이지로 변경, 히스토리에 기록하지 않음. (removes the URL of the current document from the document history) => replace()의 경우 뒤로가기를 통해 이전 페이지로 갈 수 없음.

관계연산자 ==, === 의 차이

==과, ===은 비슷하지만 깊게 들어가면 다른 의미를 가지고 있다. == Equal Operator=== Strict Equal Operator (strict 엄격한 이라는 의미로 좀 더 엄격하게 같은 지를 보는 연산자라 생각하면 됨.) == 연산자는 피 연산자가 서로 다른 타입이면 타입을 강제로 변환하여 비교.ex) 0 == '0' => true 0 == 0 => true === 연산자는 타입까지 비교.ex) 0 === '0' => false 0 === 0 => true ex) null == undefined => true null === undefined => false null 값이 없음을 명시적으로 표시, null 값을 할당 받은 상태 (객체 타입)undefined 변수 선언만 하고 값을 할당하..

자바스크립트 데이터 타입

NaN (Not a Number) - 해당 값이 숫자가 아니다.ex) parseInt("hello", 10); isNan() - 해당 데이터가 NaN인지 검사 해주는 자바스크립트 내장객체true = NaNfalse = Number Infinity - 0보다 큰 양의 무한대Infinity - 0보다 작은 음의 무한대 isFinite() - 인자값이 숫자이면서 무한대가 아니면 true,NaN 혹은 Infinity, -Infinity 이면 false Null - 값이 없음의도적으로 비어있는 값을 부여한 것 undefined - 초기화(선언) 되지 않았거나 값이 할당되지 않았음을 나타냄애당초 어떠한 값도 할당되지 않은 것

userAgent 구분 스크립트 (Android/iOS/Mobile)

/** * Android 단말기 인지 확인 */this.isAndroid = function() {try{ return (/android/i.test(navigator.userAgent.toLowerCase()));} catch(e) {self.log(e,"isAndroid");}}/** * iOS 단말기 인지 확인 */this.isIos = function() {try{return (/iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase())); } catch(e) {self.log(e,"isIos");}}/** * 모바일인지 판별한다. */this.isMobile = function() {try {return (/iphone|ipad|ipod|androi..

반응형