I find this notation everywhere in Webpack generated libs but I don't understand it :
var a = (0, _parseKey2.default)(something)
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.
Thanks for your help.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With