1
누구나 isSharp
이 아래 코드의 global context
에있는 방법을 알려 줄 수 있습니까? 나는 존의 Advanced JS를 따랐다. 개체에서 실행되지 않는 코드에서컨텍스트는 정확히 무엇을 나타 냅니까?
function katana(){
this.isSharp = true;
}
katana();
alert(isSharp);
assert(isSharp === true, "A global object now exists with that name and value.");
var shuriken = {
toss: function(){
this.isSharp = true;
}
};
shuriken.toss();
assert(shuriken.isSharp === true, "When it's an object property, the value is set within the object.");
아마도 MDN의 [this 키워드] (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this)를 읽어야합니다. – Bergi