@vicky At first glance, this code snippet might look bananas. But let’s take a look at a similar one: console.log(['b', 'a', 'n', 'a', 'n', 'a'].join("").toLowerCase()). That’s not too crazy! An array of characters that are joined to a string. Okay, there’s not really a character type in JavaScript; it’s an array of strings. But you get the idea. 😊
So the real question is, how come [({}+[])[2] and company are evaluted as characters? Let’s fire up a JavaScript console and see what happens when we run toString on an empty object: ({}).toString() ⇒ "[object Object]".
Aha, a string is returned! And whenever we have a string, we can grab single characters from it with the charAt method: ({}).toString().charAt(2) ⇒ "b". The same thing can be accomplish using bracket notation ([]): ({}).toString()[2] ⇒ "b".
Another property of JavaScript is that when you add an object and array together, you will get a string back: ({}+[]) ⇒ "[object Object]".
Add all this together, and you will end up with the familiar first sequence from your puzzle: ({}+[])[2] ⇒ "b". 😅 The code relies on similar JavaScript quirks to generate the rest of the banana, so to speak. 🍌