Recently I came across an interesting snippet of JavaScript.
{} + [] = 0
Oops and the result is 0. How is this addition of objects being carried out? What's going behind the scenes? Does anyone have any idea?
Recently I came across an interesting snippet of JavaScript.
{} + [] = 0
Oops and the result is 0. How is this addition of objects being carried out? What's going behind the scenes? Does anyone have any idea?
if you are useing chrome to execute the code, if so, V8 dynamically creates hidden classes behind the scenes v8
{} is equal to new Object() and [] is equal to new Array() but this is for declaration. When i addition {} + [] this, i am geting string "[object object]" and length equals to 15.Aslo i am using chrome.