Primitives vs. Objects, Ruby-like features

Jason Orendorff jason.orendorff at
Fri Mar 28 08:53:12 PDT 2008

On Mon, Mar 24, 2008 at 9:43 PM, Darryl <psygnisfive at> wrote:
> typeof(1) == "number"
> typeof(new Number(1)) == "object"
> Will these be made uniform in JS2?

No, it would be a pretty big breaking change from ES3.  ES4 is
considering several small breaking changes, but nothing this major.

I feel your pain though.

>  5.prototype //parse error
>  function N(n){ return n }
>  N(5).prototype //== Number, wtf?

In Mozilla's JS engine, at least, `N(5).prototype` here evaluates to

`N(5).whatever` and `(5).whatever` and `5..whatever` are all
identical, as Brendan said.  I'm pretty sure ES3 requires this.  If it
doesn't work for you, there's a bug somewhere.

Anyway, the syntax error on "5.prototype" seems impossible to fix
without breaking compatibility.  Consider:

  var x = 5.e6;  // exponential notation or property lookup?

I like some things about Ruby, but language design isn't a matter of
collecting all the language features you like.  It's ok for ECMAScript
and Ruby to be delightful in different ways.  Adding some Ruby-like
syntax to ECMAScript could surely be done, but it would radically
change the feel of the language.  I think most JS users would be

The problems solved by Ruby's flexible syntax and Ruby blocks might be
addressed in ES5 (or later) by a macro system.  We'll see.


More information about the Es4-discuss mailing list