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.
What is this? In JavaScript, the this keyword refers to an object. Which object depends on how this is being invoked (used or called). The this keyword refers to different objects depending on how it is used: In an object method, this refers to the object.
“This” keyword refers to an object that is executing the current piece of code. It references the object that is executing the current function. If the function being referenced is a regular function, “this” references the global object.
“this” inside FunctionsThe value of this inside a function is usually defined by the function's call. So, this can have different values inside it for each execution of the function. In your index. js file, write a very simple function that simply checks if this is equal to the global object.
In JavaScript, the this keyword allows us to: Reuse functions in different execution contexts. It means, a function once defined can be invoked for different objects using the this keyword. Identifying the object in the current execution context when we invoke a method.
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