본문 바로가기

자바스크립트11

[Javascript 기초] 전개 연산자 전개 연산자는 배열의 요소나 객체를 전개해주는 연산자입니다. 배열이나 객체를 복사하여 여러 개의 배열이나 객체를 병합할 수 있습니다. // 구문 myFunction(...iterableObj); 1. 배열에서의 전개 연산자 // 배열 복사 let colors = ["red", green, "blue"]; let colors2 = ["pink, ...arr"]; console.log(arr2); // ['pink', 'red', 'green', 'blue'] // 배열 병합 let hobby = ["game", "sports", "reading"]; let hobby2 = ["dance", "climbing", "skating"]; let newHobby = [...hobby, ...hobby2]; con.. 2023. 6. 3.
[Javascript 기초] 비구조화 할당(구조 분해 할당) 비구조화 할당(구조 분해 할당) 구문은 배열이나 객체의 속성을 해체하여 그 값을 개별 변수에 담을 수 있는 표현식입니다. const colors = ["red, green, yellow, blue, black"]; const [color1, color2, color3, color4] = colors; console.log(color1); // red console.log(color2); // green console.log(color3); // yellow console.log(color4); // blue console.log(color5); // black const peopleA = { name : "Tom", age : 23, isFemale : false, hobby : "exercise" } .. 2023. 6. 3.
[Javascript 기초] 숫자 관련 객체 Math 숫자 관련 객체 1. Math.round() 2. Math.pow() 3. Math.sqrt() 4. Math.abs() 5. Math.ceil() 6. Math.floor() 7. Math.min() 8. Math.max() 9. Math.random() 1. Math.round() Math.round(x)는 입력값 x에서 제일 근접한 정수를 반환합니다. (반올림, 반내림) console.log(Math.round(4.3)); // 4 2. Math.pow() Math.pow(x, y)는 x에 y를 제곱한 값을 반환합니다. console.log(Math.pow(2, 4)); // 16 3. Math.sqrt() Math.sqrt(x)는 x의 제곱근을 반환합니다. console.log(Math.sqrt(.. 2023. 5. 31.
[Javascript 기초] 날짜 관련 객체 Date 날짜 관련 객체 1. new Date() 2. new Date().getTime() 3. new Date().getFullYear() 4. new Date().getMonth() 5. new Date().getDate() 6. new Date().getHours() 7. new Date().getMinutes() 8. new Date().getSeconds() 1. new Date() Date() 생성자는 날짜 정보값을 반환합니다. console.log(new Date()); // Mon May 29 2023 21:50:38 GMT+0900 (한국 표준시) 2. new Date().getTime() new Date().getTime()은 1970년 1월 1일 이후부터의 millisecond 단위 숫자를 .. 2023. 5. 29.