Hacker News new | ask | show | jobs
by CyruzDraxs 5298 days ago
I'm a Javascript user. The list of things I'd change is enormous. A few of the biggest things though, is making better object looping; it's annoying having to check each property to see if it's on the object itself or it's prototype. It'd also be nice to have a build in extend/include system, rather than having all these different custom ones people use. Put jQuery and Underscore on the same page and you have two different implementations of object extension. Seems like kind of a waste of code.
1 comments

On object looping:

    Object.keys(obj).forEach(function (key) {
        var value = obj[key];
        // ...
    });
Not the best thing, but it works in less lines than:

    var key;
    for (key in obj) {
        if (!Object.prototype.hasOwnProperty(obj, key) {
            continue;
        }

        var value = obj[key];
        // ...
    }
Plus, it avoids the async-function-in-a-loop problem (which is why I rarely use C-style `for` loops or `for-in` loops now).