Advance II/JavaScript (2) 썸네일형 리스트형 [JS] call, apply, bind 자바스크립트에서는 함수 호출 방식과 관계없이 this를 지정할 수 있다. call 모든 함수에서 사용할 수 있으며, this를 특정 값으로 지정할 수 있다. 함수명.call(this로 사용할 객체, 함수에 전달할 파라미터...) const mike = { name: "Mike", }; const tom = { name: "Tom", }; function showThisName() { console.log(this.name); // window.name } function update(birthYear, occupation) { this.birthYear = birthYear; this.occupation = occupation; }; showThisName(); // 빈 문자열 //함수명.call(thi.. [JS] JavaScript Algorithms and Data Structures Basic JavaScript let 이나 const 키워드 없이 생성된 변수는 자동적으로 글로벌 스코프에 생성된다. 함수나 블럭 안에 정의할지라도 어디서나 접근 가능 >, >=, arrow function syntax (ES6) const myFunc = () => { const myVar = "value"; return myVar; } -> 함수 body가 없고 return 값만 있는 경우 const myFunc = () => "value"; const multiplier = (item, multi) => item * multi; multiplier(4, 2); Default Parameters const greeting = (name = "Anonymous") => "Hello " + name; c.. 이전 1 다음