News for hackers. Stuff that matters.
Re:Modern Javascript: Everything you missed over the last 10... by nsonha on Saturday May 15, 2021 @12:29PM (#27166624)
Example of inconsistencies? comparing to what? If you're gonna cherry pick some outdated es5 to make that point, dont bother.
Re:Modern Javascript: Everything you missed over the last 10... by makapuf on Saturday May 15, 2021 @01:01PM (#27166913)
Iterating over an object keys, an array or a map?
Re:Modern Javascript: Everything you missed over the last 10... by frankenst1 on Saturday May 15, 2021 @06:01PM (#27169419)

    let obj = {a:1},
        arr = [1], 
        map = new Map().set("a",1);    

    // Iterating over an object keys
    for (let x of Object.keys(obj)) {...}

    // an array
    for (let x of arr) {...}

    // or a map?
    for (let x of map) {...}
Re:Modern Javascript: Everything you missed over the last 10... by kingdomcome50 on Saturday May 15, 2021 @01:18PM (#27167034)
I would expect, given you have described an operation on 3 different data structures using different words, that it would also demand 3 different kinds of syntax/denotation no? Your own language requires as much. Why not JS?
Re:Modern Javascript: Everything you missed over the last 10... by makapuf on Saturday May 15, 2021 @02:03PM (#27167445)
Well in python by example you use for x in myobject to iterate and that's it, no Object.entries(myobj) vs. mymap.entries , lua is even more consistent, ..
Re:Modern Javascript: Everything you missed over the last 10... by nsonha on Saturday May 15, 2021 @09:46PM (#27170525)
Hey what about map and comprehension? This is a language that claims to value "one way to do things"
Re:Modern Javascript: Everything you missed over the last 10... by stevula on Saturday May 15, 2021 @07:17PM (#27169822)
It’s not uncommon in Python to iterate through dict.items() (or dict.keys()) which is basically the same thing.