Jquery and IIFE wrapper clarification?

前端 未结 1 988
谎友^
谎友^ 2021-01-25 02:32

The window can not be redefined like we see in this example:

http://i.stack.imgur.com/IYX0p.jpg \"ent

相关标签:
1条回答
  • 2021-01-25 03:12

    I guess a possible explanation is to make JQuery easier to port in other contexts, where the global object may not be named window, or even embedded in some other scripts, in the case window refers to a valid token in the current scope (or in the activation object).

    Anyway, the only reason why I think this may be useful is because the jQuery code can use the windowname without worry, because any vendor can bind the name to whatever object it wants, only by changing a single line of the jQuery source (the last one).

    0 讨论(0)
提交回复
热议问题