This commit is contained in:
Yofri 2017-06-26 20:42:44 +07:00
parent 7da4376fda
commit d2691263ce

View file

@ -421,7 +421,7 @@ alert( [1] + 1 ); // "11"
alert( [1,2] + 1 ); // "1,21"
```
Arrays do not have `Symbol.toPrimitive`, neither a viable `valueOf`, they implement only `toString` conversion, so here `[]` becomes an empty string, `[1]` becomes `"1"` and `[1,2]` becomes `"1,2".
Arrays do not have `Symbol.toPrimitive`, neither a viable `valueOf`, they implement only `toString` conversion, so here `[]` becomes an empty string, `[1]` becomes `"1"` and `[1,2]` becomes `"1,2"`.
When the binary plus `"+"` operator adds something to a string, it converts it to a string as well, so the next step looks like this: