[ ]+{ }
: An array plus an object.
Addition performs implicit type conversion, with the rule of calling its valueOf() or toString() to obtain a non-object value (primitive value).
If either of the two values is a string, string concatenation is performed; otherwise, numeric addition is performed. Both [ ] and { } return themselves from valueOf(), so toString() is called, resulting in string concatenation.
[ ].toString() returns an empty string, ({ }).toString() returns "[object Object]", and the final result is "[object Object]".
{ }+[ ]
: It seems to be the same as above.
However, besides representing an object, { } can also represent an empty block. In [ ] + { }, [ ] is interpreted as an array, so the following + is interpreted as an addition operator, and { } is interpreted as an object.
But in { } + [ ], { } is interpreted as an empty block, and the following + is interpreted as a unary plus operator. In other words, it actually becomes: {∥empty block}+[ ], which means performing a unary plus operation on an empty array, which is essentially converting the array to a number. First, valueOf() is called, returning the array itself, which is not a primitive value, so [ ].toString() is called, returning an empty string. The empty string is converted to a number, returning 0, which is the final result.