// args는 배열
function getAllParamsByRestParameter(...args) {
return args;
}
// arguments를 통해 '비슷하게' 함수의 인자들을 다룰 수 있습니다. (spread syntax 도입 이전)
// arguments는 모든 함수의 실행 시 자동으로 생성되는 '객체'입니다.(유사배열...)
function getAllParamsByArgumentsObj() {
return arguments;
}
const restParams = getAllParamsByRestParameter('first', 'second', 'third');
const argumentsObj = getAllParamsByArgumentsObj('first', 'second', 'third');
restParams // ["first", "second", "third"]
argumentsObj // ["first", "second", "third", callee: ƒ, Symbol(Symbol.iterator): ƒ]
Object.keys(argumentsObj) // ["0", "1", "2"]
Object.values(argumentsObj) // ["first", "second", "third"]
const argsArr = Array.from(argumentsObj);
argsArr // ["first", "second", "third"]
전역에 코드가 작성되면 전역 메모리 테이블이 만들어진다. 그 테이블에는 이름과 값(또는 주소)이 들어있다. 이를 global excution context(전역 실행 컨텍스트)라고 한다.
만약 function을 콜한다면?? -> Local memory가 생성이된다. 이를 local excution context라고 한다.
JavaScript - This, function Method을 복습 추가하면서 진행하고 koans문제를 풀이함~