You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// argument는 parameter에 영향을 준다functionfoo(a,b){a=1arguments[0]=2console.log(a,arguments[0])}foo(10,20)
functionf(x,y){// 나머지를 처리하기 위한 기존 로직varrest=Array.prototype.slice.call(arguments,2)console.log(rest)}f(1,2,true,null,undefined,10)
// ... 나머지로 쓸 수 있음 constf=function(x,y, ...rest){console.log(rest)}f(1,2,true,null,undefined,10)
5-2. 상세
1) ...[매개변수명]
2) 오직 한 번, 매개변수의 가장 마지막에서만 사용가능
// Uncaught SyntaxError: Rest parameter must be last formal parameterconstf=function(_first, ...rest,_last){console.log(_first,_last)}f(1,2,3,4,5,6,7,8,9,10)
3) 객체의 setter에서 사용불가
하나의 key 에는 하나의 value 밖에 없음, 1:1 대응이기에 setter 함수에는 restparameter 사용 불가