mdn

· JAVASCRIPT
표준내장객체 (standard built-in object) Date에 관한 내용을 정리했다. 자세한 내용은 mdn 문서를 참조하자. // Date const date = new Date(); console.log(date); // Sat Apr 15 2023 20:24:49 GMT+0900 (한국 표준시) // new Date(년, 월, 일, 시, 분, 초); console.log(date.getFullYear()); // 2023, 연도를 반환 // setFullYear : 연도를 설정(setter) // getMonth(), setMonth() // 날짜 인스턴스의 월을 반환하거나 지정 // 0부터 시작 (1월 = 0, 2월 = 1, 12월 = 11) console.log(date.getMonth(..
· JAVASCRIPT
숫자의 표준내장객체는 아래 서술한 것보다 많이 존재한다. 자세한 것은 mdn문서를 참조하자. // toFixed(), 숫자를 지정된 고정 소수점 표기(자릿수)까지 표현하는 문자로 반환. const num = 3.1415926535; console.log(num.toFixed(2)); // 3.14 (string) console.log(parseFloat(num.toFixed(2))); // 3.14 (number) console.log(typeof num.toFixed(2)); // string console.log(typeof parseFloat(num.toFixed(2))); // number // toLocaleString(), 숫자를 현지 언어 형식의 문자로 반환. const num1 = 1000..
· JAVASCRIPT
표준내장객체는 아래 서술한 것보다 더 많다. 자세한 건 mdn문서를 살펴보자. //표준내장객체(Standard Built-in Object) // 자바스크립트가 기본적으로 가지고 있는 객체들을 의미한다. const str = "Hello world!" //length, 문자열의 길이를 반환 console.log(str.length); //12 //includes(), 대상 문자에 주어진 문자가 포함되어 있는지 확인한다.(Boolean) console.log(str.includes('Hello')); //true //indexOf(), 대상 문자에서 주어진 문자와 일치하는 첫 번째 인덱스(숫자)를 반환. 일치하는 문자가 없으면 '-1'을 반환. console.log(str.indexOf('world'));..