Why is it that this code evaluates to:
10 + "10" => "1010"
"10" + 10 => "1010"
and why does it not work like this:
10 + "10" => 20 // the number comes first
"10" + 10 => "1010" // the string comes first
EDIT:
More specifically, where in the implementation of the interpreter does it do this? Or, how does it do this?
The ECMAScript 262 Specification codifies the JavaScript language (JavaScript is actually the Mozilla implementation of ECMAScript). In any case, things are relatively easy to find in Annotated ES5 which I usually consult.
See 11.6.1 The Addition operator ( + ):