티스토리 뷰
this 는 또 다른 인자 같은 존재, 호출하는 순간, 호출하는 모양새에 따라 어떤 객체를 가르킬지 결정된다고 합니다.
함수 형태(Function form)
functionObject(arguments);
이 경우, 'this'는 전역객체.
메서드 형태(Method form)
thisObject.methodName(arguments); thisObject["methodName"](arguments);
이 경우는, 'this'는 thisObject.
생성자 형태(Constructor form)
new functionObject(arguments);
생성자 형태에서 'this'는 새로운 객체.
여담으로, 생성자 형태에서 특별한 리턴 값이 없을 경우, 새롭게 생성된 객체 즉, this를 리턴하게 됩니다.
apply 형태
functionObject.apply(thisObject, [arguments]);
마지막으로, 'this'는 thisObject.
출처: YUI Theater: Douglas Crockford, The JavaScript Programming Language
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- console
- 커피스크립트
- Git
- VI
- Eclipse
- React
- Java
- reactiveprogramming
- JavaScript
- 리액티브프로그래밍
- Windows
- intellij
- 윈도우즈
- gvim
- tipoftheday
- 자바스크립트
- 자바
- Coffeescript
- maven
- dojo
- 리액터
- VIM
- 빔
- REACTOR
- Widget
- unit test
- Node.js
- 스프링인액션
- Commonjs
- Configuration
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함