String.prototype.charAt(0) // 0번째 글자
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt
String.prototype.substr(3) // 3번 이하 글자 모두
String.prototype.substr(1,7) // 1번포함 글자~ 7번포함 글자
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
제곱근
Math.sqrt(-1); // NaN
Math.sqrt(-0); // -0
Math.sqrt(0); // 0
Math.sqrt(1); // 1
Math.sqrt(2); // 1.414213562373095
Math.sqrt(9); // 3
Math.sqrt(Infinity); // Infinity
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt
Number.parseInt() // 정수로 만들어줌
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt
parseInt(string, radix) => string:숫자로 변환할 문자열, radix : 문자열의 진수
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/parseInt
Math.min(…arr) // arr의 가장 작은 값을 반환
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Math/min
스플라이스!! 떼서 붙이는거
Array.splice(1,0,idx) // 1번부터 0개 제거 1번에 idx추가
Array.splice(4,1,idx) // 4번부터 1개 제거 4번에 idx추가
Array.splice(3,1) // 3번째부터 1개까지 제거
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
슬라이스!! 잘라버리는거
Array.slice(2,4) //2번째 포함 4번째 앞까지(미포함)해서 반환
Array.slice(2,-1) //2번째 포함 뒤에서 1번째(미포함)해서 반환
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
스플릿! 괄호안에 있는걸로 다 나눠버린다!
String.prototype.split()
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/split
Object.prototype.toString(2) //2진법으로 변환
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
Math.round() // 반올림
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Math/round
destructuring
function settings() {
return { display: { color: 'red' }, keyboard: { layout: 'qwerty'} };
}
const { display: { color: displayColor }, keyboard: { layout: keyboardLayout }} = settings();
console.log(displayColor, keyboardLayout); // red qwerty
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
for…of
const array1 = ['a', 'b', 'c'];
for (const element of array1) {
console.log(element);
}
// expected output: "a"
// expected output: "b"
// expected output: "c"
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/for...of
String.prototype.substring()
const str = 'Mozilla';
console.log(str.substring(1, 3));
// expected output: "oz"
console.log(str.substring(2));
// expected output: "zilla"
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
Array.prototype.filter()
arr.filter((element,index)=>element != arr[index+1]) //element :처리할 현재 요소,index:처리할 현재 요소의 인덱스, thisArg : 콜백할때 this값
arr.filter(function name) => function name의 함수로 filter가 정렬됨
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/filter