JavaScript this refers to window instead of object inside function

前端 未结 3 2004
既然无缘
既然无缘 2020-12-06 06:26

I get confused on a JavaScript this reference situation.

I am working on a code that I declare function inside an object method. (The reason is to tidy

3条回答
  •  抹茶落季
    2020-12-06 06:28

    The this, references is not related to scope, it depends on the calling context.

    As per the MDN doc,

    In general, the object bound to this in the current scope is determined by how the current function was called

提交回复
热议问题