Reputation: 15
I have been studying JavaScript lately, but I am not getting the [undefined] - x something is -x but undefined - x is NaN...
console.log(undefined-3); //NaN
console.log([undefined]-3); // -3
Upvotes: 0
Views: 126
Reputation: 331
The explanation : (Give your feedback)
Before the calculation, the compiler will try to convert "undefined" and "[undefined]" to a typeof number.
And the result is :
Check the list of JavaScript type Conversion here.
Upvotes: 2