this
index.html
<html>
<script>
console.log(this); //window
</script>
</html>function test() {
console.log(this); // window
}Last updated
index.html
<html>
<script>
console.log(this); //window
</script>
</html>function test() {
console.log(this); // window
}Last updated
var obj1 = {
data : 'data',
fun1 : function() {console.log(this)}
}
obj1.fun1(); //obj1์ด ์ถ๋ ฅ๋๋ค.var obj2 = {
data : {
fun2 : function() {console.log(this)}
}
}
obj2.data.fun2(); // this๋obj2.data<script>
function fun1() {
console.log(this);
}
window.fun1 = function() {
console.log(this)
}
//์ ์ฝ๋๋ ๋๋ค ๊ฐ์ ๋ด์ฉ์
</script>function fun3() {
this.name = 'Lee';
}var obj3 = new fun3();
console.log(obj3.name); //'Lee'๊ฐ ์ถ๋ ฅ๋จ