Re:The Secret Life of JavaScript Primitives
by TrevorBurnham on Monday September 05, 2011 @10:46AM
(#2962329)
True. I'd argue that it's the best of both worlds: Unlike Java, you have access to a bunch of helpful functions on every primitive, and you can add more by modifying prototypes; and unlike Ruby, primitives are immutable, which puts a cap on the level of complexity (you could write a whole book on Ruby's string objects).
[ Parent
| on HN ]
Re:The Secret Life of JavaScript Primitives
by LeafStorm on Monday September 05, 2011 @11:26AM
(#2962448)
You could do something similar by having each primitive type share a global prototype á la Lua's "string" metatable. Most operations are implemented as primitives in the VM, but any non-primitive operations on primitive types go to the type's metatable.