this
함수와 this
1. 함수호출
function func(){
if(window === this){
document.write("window === this");
}
}
func();
// window === this
//this는 전역객체인 window와 같다2. 메소드의 호출
var o = {
func : function(){
if(o === this){
document.write("o === this");
}
}
}
o.func();
//o === this (o === window.o)3. 생성자의 호출
3-1. 생성자를 만들기 전에 함수를 실행했을 때?
4. apply, call을 이용한 this의 값 제어
Last updated