Avatar ·

Why does ++[[]][+[]]+[+[]] return the string "10" in JavaScript?

Hi everyone! I'm learning JavaScript and came across some very strange code. I saw this expression in an article: ```javascript console.log(++[[]][+[]]+[+[]]); // Outputs "10" ``` I don't understand how this works at all. Why does an array, plus plus, an empty array in square brackets, and plus an empty array produce the string "10"? I know that JS has type coercion, but this looks like some kind of magic. I tried to break it down into parts, but got even more confused. For example, what does `++[[]]` mean? Or `+[]`? How does this all result in exactly "10" and not something else? Could someone explain step by step what exactly is happening in this expression? I would be very grateful for a detailed explanation, because I want to understand how operators and type coercion work in JavaScript at a deep level. Thanks!