ECMAScript 5: The Long-Awaited Javascript Update

Ten years in the making, Javascript 5 doesn’t break new ground but contains useful enhancements.

In other words, when you have a function, you can call the function’s bind function. Pass in an object, and the function will become a member of that object. The object now has a member function identical to the function you started with.

Now, technically speaking, the function itself hasn’t changed. It’s still there and you can use it. Instead, the ECMAScript engine creates a new function identical to the original in all ways, except that new function is now a member of the object.

As with the JSON support, this is actually not new either. There’s a popular JavaScript library called PrototypeJS. This library includes a bind function that does exactly what I’m talking about here. (In fact, it’s identical to the point that it’s clear the ECMAScript designers based their bind function on PrototypeJS’s bind function.) You can read about it here.

Other Enhancements

There are also several smaller enhancements to ECMAScript. I already mentioned the handful of new functions that exist on the main Object object. The Array object now includes in its prototype several handy new functions that will make your array-manipulation life easier; such as indexOf, map, filter and others. Strings now include a trim function, and the basic objects; String, Boolean, Number and Date, now include prototype functions for converting to JSON strings. To see the full list, have a look at the page I mentioned earlier.