eval on non-strings

Corey Richardson corey at octayn.net
Sun Feb 26 03:09:36 PST 2012

On Sun, 26 Feb 2012 11:57:44 +0100, Xavier MONTILLET <xavierm02.net at gmail.com> wrote:
> Or it should call its toString method.

That would introduce unwanted side effects. Sondier this:

eval([1, 2, 3]) right now returns [1, 2, 3]. But [1, 2, 3].toString() is
'1,2,3', so you'd have eval('1,2,3') which returns 3. That makes even less
sense than just returning what was given.

I really don't think anything but an exception is good there (perhaps limited
to strict mode or something?)

Corey Richardson

More information about the es-discuss mailing list