
本文共 2278 字,大约阅读时间需要 7 分钟。
IIFE������ Immediately Invoked Function Expression������������������������������������������������JavaScript���������������������������������������������������������������������������������������������������������������������������������������������������������������IIFE������������������������������������������JavaScript���������������������
IIFE���������
- ���������������IIFE���������������������������������������������������������������������������������������������������������������������������������
- ������������������������������������IIFE������������������������������������������window������������������������������������������������
- ���������������������������������������������������������������������������������
������������������
���������������������
var a = 4console.log(a)(function() { var a = 1 function test() { console.log(++a) } function test2() { console.log('test2()') } window.$ = function() { return { test: test } }})$().test() // ������: 1, ���������������test������
- IIFE������
(...)
������������������������������������������������������������ - ���������������
var a = 1
������������������a = 4
��������������� - ���������������������������
test
������������������������������������������������������window.$ = ...
������������������������������������������������������������ $().test()
������������IIFE���������window.$
���������������������������������������������
������this
���������
this
���������������������������������������������������������������this
���������������������������������������
this
������������������������������window
������this
������p
���������this
������������������test
���������this
���������������������obj
������������������������������������������������������������������������������������������this
���������������������������������������������������������������������
������������
���������������������������������������������������������������������������������IIFE������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
