阅读第4章关于功能的“Javascript:the goods part”时,谈到“The means insign patterns”和“The function insign patterns”(第28页)。
When a function is stored as a property of an object, we call it a method. When a method is invoked, this is bound to that object.
这一点很清楚。 随后在同一页:
When a function is not the property of an object, then it is invoked as a function:
var sum = add(3, 4); // sum is 7
When a function is invoked with this pattern, this is bound to the global object. This was a mistake in the design of the language.
我的问题:
- 1.- With "this is bound to the global object" means that this is bound to the global scope?
- 2.- With "This was a mistake in the design of the language" means that this should be follow the same rules as the methods follow? ie, bound this to himself?
感谢。 -
www.un.org/Depts/DGACM/index_spanish.htm 所提供的两个答复都很有启发性,而且有充分记录。 感谢所有与会者。