04.01.2015, 07:36, "Brendan Eich" <[email protected]>:
My point is: concatenating Symbols with other strings have legitimate
uses.Name one.
I did name one in another message. Logging. If somebody wants to output a variable just to see what it is, something like `console.log('hey, I got this: ' + variable)` would be a natural choice.
People don't expect string concatenation to throw. So they will happily write something like:
```
function debug() {} // logging function in development, no-op in production env
function something(x) {
debug('something called with ' + x)
}
```
Which would fail whenever somebody passes a symbol there.
I would assume `console.log(array.join(','))` would work as long as `array` is a array. Right? Wrong. As long as there is a Symbol() in there, it would throw. And unexpected behavior is never a good thing.
Yes, it does sound hypothetical, but so does `object['' + Symbol()]` case which throwing is supposed to solve. I don't believe that casting is that common of an issue to outweight all the costs this behavior introduces.
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

