eval on non-strings

Mark S. Miller erights at google.com
Tue Feb 28 09:20:42 PST 2012

On Tue, Feb 28, 2012 at 7:54 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

> There is also a matter of maintaining internal insistency within a
> language. [...] JS generally converts primitive values to wrapper objects
> whenever one is used in a context that requires an object. [...]

Some other violations of this rule that surprised me when I first came
across them:

> 3 instanceof Number
> 'x' in 3
TypeError: Cannot use 'in' operator to search for 'x' in 3

I am not suggesting that we do anything to repair these -- it is likely too
late. But depending on how many other such irregularities there are, it may
not altogether be clear which direction the principle of least surprise
should take us.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120228/ccbf1dcb/attachment.html>

More information about the es-discuss mailing list