TIL_21.01.06

nRecode·2021년 1월 6일
0

TodayILearned

목록 보기
81/95
post-thumbnail

Spread Syntax

// 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"]

JS에서 This

전역에 코드가 작성되면 전역 메모리 테이블이 만들어진다. 그 테이블에는 이름과 값(또는 주소)이 들어있다. 이를 global excution context(전역 실행 컨텍스트)라고 한다.

만약 function을 콜한다면?? -> Local memory가 생성이된다. 이를 local excution context라고 한다.

JavaScript - This, function Method을 복습 추가하면서 진행하고 koans문제를 풀이함~

profile
안정성, 확장성 있는 서버를 구축하고 가꾸는 개발자를 목표로 공부하고 있습니다. 🤔🤔🤔🤔 부족하기에 맞지 않는 내용이 있을 수 있습니다. 가감없이 피드백 해주시면 정말 감사하겠습니다..🙏

0개의 댓글