Hacker News new | ask | show | jobs
by polymeris 3219 days ago
> it's impossible to go back.

I too, am learning JS in 2017, and I can't wait to go back (to cljs). Or away, to anything else. I had done some basic stuff before, but for the last days I have been writing some code for a larger SPA.

Just as an example, today I needed to do the simple task of iterating over a dictionary. I expected it to go roughly like this:

    dictionary.forEach(this.someMethod);
Instead, this is apparently what passes for sane in JS world, in 2017:

    for (var key in dictionary) {
        if (dictionary.hasOwnProperty(key) {
            this.someMethod(key, dictionary[key]);
        }
    }
1 comments

There are other options, closer to what you're looking for. Try

    Object.entries(dict).forEach(fn)
Or

    _.entries(dict).forEach(fn)