본문 바로가기

HTML/JS/CSS

(52)
Nullish coalescing operator (널 병합 연산자 ??) - 널병합연산자 (Nullish coalescing operator) - ?? // ?? 의 왼쪽 값이 Null, Undefined 일 때 ?? 오른쪽 값 대입 function printMessage(text){ const message = text ?? 'Nothing to Display'; console.log(message); } 비슷하지만 다른 Logical OR - || // Logical OR 왼쪽 값이 falsy 한 값 일 때 Logical OR 오른쪽 값 대입 // Falsy : https://developer.mozilla.org/ko/docs/Glossary/Falsy function printMessage3(text){ const message = text || 'Nothing to ..
웹페이지에서 카메라 보이기 developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia MediaDevices.getUserMedia() - Web APIs | MDN The MediaDevices.getUserMedia() method prompts the user for permission to use a media input which produces a MediaStream with tracks containing the requested types of media. That stream can include, for example, a video track (produced by either a hardware developer.mozilla.org develop..
[JS] 함수형 프로그래밍 할 때 생각해볼 몇가지. 함수형 프로그래밍 생각해보야 할 몇 가지. 1. 함수를 되도록 작게 만들기. 2. 다형성 높은 함수 만들기. 3. 상태를 변경하지 않거나 정확히 다루어 부수 효과를 최소화하기. 4. 동일한 인자를 받으면 동일한 결과를 리턴하는 순수함수 만들기. 5. 복잡한 객체 하나를 인자로 사용하기보다 되도록 일반적인 값 여러개를 인자로 사용하기. 6. 큰 로직을 고차 함수로 만들고 세부 로직을 보조 함수로 완성하기. 7. 어느 곳에서든 바로 혹은 미뤄서 실행할 수 있도록 일반 함수이자 순수 함수로 선언하기. 8. 모델이나 컬렉션 등의 커스컴 객체보다는 기본 객체를 이용하기. 9. 로직의 흐름을 최대한 단방향으로 흐르게 하기. 10. 작은 함수를 조합하여 큰 함수 만들기. -- 출처 : https://www.infle..
javascript 소수점 연산. function.. function roundXL(n, digits) { if (digits >= 0) return parseFloat(n.toFixed(digits)); // 소수부 반올림 digits = Math.pow(10, digits); // 정수부 반올림 var t = Math.round(n * digits) / digits; return parseFloat(t.toFixed(0)); } 자바스크립트 소수점 자리수 계산 사용법 : roundXL(대상,자리수); 출처 : http://blog.naver.com/caesar0342?Redirect=Log&logNo=20120341657
특수문자 코드표 출처: http://www.webmini.net/43964 Hex Code Entity Code Number Code Character Description " " " Quotation Mark & & & Ampersand ⁄ / / Slash < < Greater Than Sign ‚ ‚ ‚ Single Low-9 Quote „ „ „ Double Low-9 Quote † † † † Dagger ‡ ‡ ‡ Double Dagger ‰ ‰ ‰ Per Mill Sign ‹ ‹ ‹ Single Left Angle Quote ‘ ‘ ‘ Left Single Quote ’ ’ ’ Right Single Quote “ “ “ Left..
[JS] 모바일 페이지 바로가기. //모바일 페이지로 이동.//http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phonesvar uAgent = navigator.userAgent.toLowerCase();var mobilePhones = new Array('iphone','ipod','android','blackberry','windows ce',        'nokia','webos','opera mini','sonyericsson','opera mobi','iemobile');for(var i=0;i    if(uAgent.indexOf(mobilePhones[i]) != -1)        document.location = "http://"+ locati..
httpRequest.js //XMLHttpRequest객체를 생성해 주는 getXMLHttpRequest()함수 function getXMLHttpRequest() { if (window.ActiveXObject) { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e1) { return null; } } } else if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else { return null; } } //생성된 XMLHttpRequest객체를 저장할 전역변수 var httpRequest = n..
"지금 보고 있는 웹페이지 창을 닫으려고 합니다..." 안나타나게 하기 출처 : http://naver.catchstyle.net/90091110491 self.close() 시 사용했던 소스. 자기 자신의 파일명을 써줬던 것 같다. 출처 : http://naver.catchstyle.net/90091110491