function 함수2(...파라미터들) {
console.log(파라미터들);
}
함수2(1, 2, 3, 4, 5);
function 함수3(a, b, ...파라미터들) {
console.log(파라미터들);
}
함수3(1, 2, 3, 4, 5);
function 함수4(a, b, ...파라미터들) {
console.log(파라미터들[2]);
}
함수4(1, 2, 3, 4, 5);
//5
function 함수5(...rest) {
for (var i = 0; i < rest.length; i++) {
console.log(rest[i]);
}
}
함수5(1, 2, 3, 4, 5);
//1~5출력
function 함수6(a, ...rest) {
for (var i = 0; i < rest.length; i++) {
console.log(rest[i]);
}
}
함수6('시작', '시작2', 3, 4, 5, 34, 34, 234, 123, 41, 235, 123, 5,);
// ...rest 파라미터는 주의점
// 1.가장 뒤에 써야함
// 2.2번이상 금지
Object 생성기계인 constructor (0) | 2021.08.26 |
---|---|
Spread,rest 파마미터 (0) | 2021.08.26 |
자바스크립트 함수 default parameter/arguments (0) | 2021.08.24 |
Sread Operator / 펼침연산자 활용 (0) | 2021.08.24 |
자바스크립트가 문자 다루는 신기한 방법 (Template literals) (0) | 2021.08.23 |