What type conversion happens internally in javaScript when we console ( [] +50) or ([] -50)?

时间:2019-04-08 12:55:11

标签: javascript

When I console the below expressions I get the following results. Can anyone explain what is internally going on in javascript? Why adding an empty array with integer results to string?

console.log([] + 50); // "50"
console.log([] - 50); // -50

console.log({} + 50); // "[object Object]50"
console.log({} - 50); // NaN

0 个答案:

没有答案