ES has "new Constructor()" as its basic syntax for construction. This
means that if other constructors are also beneficial that the syntax
to call them is inconsistent. For example, ES3 had the
"String.fromCharCode" and ES5 added "Object.create". These are both
constructors of sorts. Would it be possible to add "String.new" etc so
that construction is consistent?

Unfortunately Date.now, Date.parse, Date.UTC don't return Date objects
as they would be elegant cases of being other constructors.

Yes in order to get consistent syntax, host objects would need to
implement the static "new" method.

(I remember the idea of being able to write "String.new" rather than
having to write "String['new']" was discussed in the past. I don't
know if keywords as bare object keys are allowed in ECMAScript but it
seems to work in Firefox.)

Peter
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to