Get the latest tech news
Why does ++[[]][+[]]+[+[]] return the string "10"?
This is valid and returns the string "10" in JavaScript (more examples here): console.log(++[[]][+[]]+[+[]]) Why? What is happening here?
First, a comment: this kind of expression is never going to show up in any (sane) production environment and is only of any use as an exercise in just how well the reader knows the dirty edges of JavaScript. Below I’ve simply added parentheses for clarity; I can assure you they change nothing, but if you want to verify that then feel free to read up about the grouping operator. As a final aside, something that may not be immediately apparent is that overriding either one of the toString() or valueOf() methods of Array.prototype will change the result of the expression, because both are checked and used if present when converting an object into a primitive value.
Or read this on Hacker News