In Yes, {} + [] = 0. No, JavaScript Isn’t Broken, @sylwia-lask uses a short JavaScript example to show how parsing can change what a plus sign does. The example makes a useful debugging exercise because it separates two questions that often get mixed together. First, what syntax did the engine recognize? Then, how did it convert the values in that syntax?
Start by identifying the statement
At the beginning of a statement in a classic script, bare opening and closing braces can form an empty block. If the next tokens are a plus sign followed by an empty array, the sign belongs to the array expression as a unary operator. The block contributes no operand. Asking what happens when the engine adds an object to an array sends the investigation down the wrong path for this version of the example.
Unary plus requests a number. For an ordinary empty array, the conversion to a primitive produces an empty string. Conversion of that empty string to a number gives zero. The equivalent numeric conversion provides a useful intermediate check when reading the script piece by piece.
Compare an expression context
Put the whole example inside parentheses and the grammar changes. The braces can now form an object literal and the plus sign sits between two operands. An ordinary empty object becomes the string containing its default object label, and an ordinary empty array becomes the empty string. Binary plus concatenates the resulting strings. Passing the expression as an argument to a function call also puts it in an expression context.
The author's reverse-order example starts with an array literal, so the same piece of punctuation is already in a binary expression. Compare it with the parenthesized version before drawing a conclusion about swapping operands. Two snippets that look similar can represent different operations. When a quick experiment seems inconsistent with a program, reproduce the same surrounding syntax first. A console input, a standalone statement, and an argument position can provide different contexts for the braces.