这个javascript语法是什么意思? (0,_parseKey2.default)(某事) [英] What does this javascript syntax mean ? (0, _parseKey2.default)(something)
问题描述
我在Webpack生成的库中找到了这个符号,但我不明白:
I find this notation everywhere in Webpack generated libs but I don't understand it :
var a = (0, _parseKey2.default)(something)
是什么(0,_parseKey2。默认)
代表什么?我不记得在函数参数的其他地方括号之间看到那些昏迷分隔的表达式,所以也许我只是缺少一些简单的东西。
What does the (0, _parseKey2.default)
stands for ? I don't remember seeing those coma separated expressions between parenthesis elsewhere that in function parameters, so maybe I am just missing something simple.
感谢您的帮助。
推荐答案
这是给 _parseKey2.default
正确的这个
(或者更确切地说,没有这个
),也就是说,将其称为普通函数,而不是方法。考虑:
This is to give _parseKey2.default
the correct this
(or, rather, no this
at all), that is, to call it as an ordinary function, not a method. Consider:
var p = {
f : function() {
console.log(this)
},
x : "foo"
};
p.f(); // { f: ... x: foo }
(p.f)(); // { f: ... x: foo }
(0, p.f)(); // implicit global this
逗号表达式是一种更简洁的方法:
The comma expression is a more concise way to do this:
var unbound = p.f;
unbound();
这篇关于这个javascript语法是什么意思? (0,_parseKey2.default)(某事)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!