나를 제외한 천재들 블로그


- '확인' 태그의 글 목록 -

확인

    [JS] 접속한 브라우저 체크하기

    [JS] 접속한 브라우저 체크하기

    예시코드 See the Pen Untitled by hyukson (@hyukson) on CodePen. 전체 코드 function getBrowser() { const browsers = [ 'Chrome', 'Opera', 'WebTV', 'Whale', 'Beonex', 'Chimera', 'NetPositive', 'Phoenix', 'Firefox', 'Safari', 'SkipStone', 'Netscape', 'Mozilla', ]; const userAgent = window.navigator.userAgent.toLowerCase(); if (userAgent.includes("edg")) { return "Edge"; } if (userAgent.includes("trident") |..

    [JS] 객체에 특정 KEY값이 존재하는지 확인하기

    includes() 사용 const obj = {a: false, b: true, c: null}; Object.keys(obj).includes('a'); // true Object.keys(obj).includes('abc'); // false Object.keys() 메서드로 객체의 모든 키값을 담은 배열을 생성해 주고, includes() 메서드로 해당 키가 존재하는지 판별해 줍니다. in 연산자 사용 const obj = {a: false, b: true, c: null}; 'c' in obj // true 'abc' in obj // false in 연산자를 사용하면 간단한 코드로 key가 존재하는지 간단하게 확인할 수 있습니다. obj.prototype.test = false; 'test' ..