My footsteps
code 실습 / 2️⃣5️⃣ 본문
728x90
// 너무 딥하게 말고 자유롭게 해보셔요들
class Exam {
constructor(math = 0) { //생성자
this.math = math;
}
}
const exam = new Exam(80);
const { math } = exam; // ⭐️ math = 80
const { math: mathScore = 90 } = exam; //math > 키 mathScore > 값
console.log(`'math : ' ${math}`); //80나올듯???? 답:80
console.log(`'mathScore : ' ${mathScore}`); //90나올거같음 답:80
// 함수 인자에서의 구조 분해
function printExam({ math }) { // ⭐️
console.log(math); //80
}
printExam(exam); //print:실행문,호출
// 배열 분해
function returnNumArrayFunction() {
return [90, 100];
}
const [math2, math3] = returnNumArrayFunction(); // ⭐️
console.log(math2); // math2:90
console.log(math3); // math3:100
728x90
'국비수업 > CODE' 카테고리의 다른 글
code 실습 / 2️⃣7️⃣ (0) | 2023.04.09 |
---|---|
code 실습 / 2️⃣6️⃣ (0) | 2023.03.31 |
code 실습 / 2️⃣4️⃣ (0) | 2023.03.29 |
code 실습 / 2️⃣3️⃣ (0) | 2023.03.21 |
code 실습 / 2️⃣2️⃣ (0) | 2023.03.20 |