[] + []
""
[] + {}
[object Object]
{} + []
0
{} + {}
[object Object][object Object] (Node/Chrome)
...or NaN (Firefox)
Array(10)
,,,,,,,,,
Array(10).join('wat')
watwatwatwatwatwatwatwatwatwat
Array(10).join('wat' + 1)
wat1wat1wat1wat1wat1wat1wat1wat1wat1wat1
Array(10).join('wat'-1) + " Batman!"
NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batman!
GetValue called on both sides of +ToPrimitive called afterGetValue + ToPrimitive => toString() then concatenateObject.prototype.toString() => '[object ' + class + ']'{}.constructor.name => 'Object'{} + {} => +{} (first {} considered as a code block)ToNumber()Array(10) => Array of 10 elements[1,2,3].join('hi') => 1hi2hi3'wat' — 1 => NaN