The following figure: I really don’t understand what this means. . .
Take a few steps to see
The first isComma operator
The general use is to evaluate from left to right and then return the last value
So:(0, 1) // 1 (0, {}) // {} (0, function () {}) // function () {}
Then you need to look at the following example:
const _utils = { func: function () { console.log(this === window) bracket bracket _utils.func(); // false let func = _utils.func func() //true (0, _utils.func)(); // true
Direct execution
_utils.func()
The inside of the functionThis
Pointed to_utils
;
When the handle_utils.func
When assigning to a variable, the functionThis
Will point to this variableWhere?The scope of, namely:Let b = {a: func} // func is 'letfunc = _ utils.func' in the above fragment. B.a() // this inside the function points to b at this time
And
(0, _utils.func)
The effect is similar to that oflet func = _utils.func
It’s about the same, but promise_utils.func
Anonymous function’sThis
CertainWill be pointed atWindow
For example:const c = { a: function () { (0, _utils.func)() bracket bracket c.a() // true
so
(0, Anonymous function) (Function Call Parameter)
The writing of the is to ensure that the function is inWindow
Execute under scope.