Stoyan Stefanov:

> What ES5 shims are you using that you can recommend?

As you know some of the general ES5 features cannot be implemented in
ES3 environment. Those which rely on internal properties and their
values in most cases cannot be emulated. For example `defineProperty',
`getOwnPropertyNames', `seal', `freeze' etc.

In other hand, some can be implemented but not exactly how
specification defines. For example `Function.prototype.bind' rely on
internal properties. Even that you are able to implement version of
`bind' which is close to the spec. Look at their `bind' <URL:
https://github.com/kriskowal/es5-shim >
According to spec. function created by `bind' does not have
`prototype' property. If you ignore this you are able to implement
`bind' in simpler way:

Function.prototype.bind = function (thisVal) {
    var target = this,
        args = [].slice.call(arguments, 1);
    function f () {
        var that = this instanceof f ? this : thisVal;
        return target.apply(that, ([].push.apply(args, arguments), args));
    };
    f.prototype = this.prototype;

    return f;
};

I think it's better when implement fallback version of certain ES5
feature to keep the essential behavior instead of implemented step by
step, how the specification defines.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to