▲ 721 ▼ Node Modules (lemmy.ml) submitted 1 year ago by cm0002@lemmy.world to c/programmer_humor@programming.dev 54 comments fedilink hide all child comments
[–] Shanmugha@lemmy.world 4 points 1 year ago (6 children) console.log([] == []) permalink fedilink source parent hideshow 6 child comments replies: [–] marlowe221@lemmy.world 2 points 1 year ago (1 child) It’s false. Different memory addresses, etc. permalink fedilink source parent hideshow 1 child comment replies: [–] Shanmugha@lemmy.world 1 point 1 year ago Like I didn't know 😂 permalink fedilink source parent [–] phoenixz@lemmy.ca 1 point 1 year ago (3 children) JavaScript sucks but I'll give it this one Arrays are complex structures with multiple values. Just because one looks like the other doesn't make them the same object. It's like taking two new objects form the same class, they look the same but work independently from eachother. I can add a value to one and the other would be unaffected, they'd both still be the same class permalink fedilink source parent hideshow 3 child comments replies: [–] Shanmugha@lemmy.world 1 point 1 year ago* (2 children) And I can't take this one. I did not ask if an object referenced by a is the same object referenced by b, I asked if two empty collections of values are equal. And an empty bag can easily be substituted by another empty bag, there is no class/instance tricky business here. And the fact that in JS arrays are objects is again JS-specific insanity. Still I thank you for sharing your thoughts permalink fedilink source parent hideshow 2 child comments replies: [–] phoenixz@lemmy.ca 2 points 1 year ago (1 child) Well it's what you'd want but not what it does, for one, but for another: comparing scalars is very easy, comparing complex structures is not. To compare one array with another you'd need to iterate over each element, recursively. That JavaScript handles arrays as objects is also not bad, that's just a language feature that you may like or not, not much can go wrong there. The reassignment of "this" or how JS handlesnumber comparison, yeah, that is infuriatingly bad permalink fedilink source parent hideshow 1 child comment replies: [–] Shanmugha@lemmy.world 1 point 1 year ago* (last edited 1 year ago) Yeah. JS is okay with lots of funny (and not fun) type coercions (toString on everything? really?), has no notion of reference as data type, but somehow automatic iteration on array by "==" operator is too much You are right, that's not want I would want from it, it is bad, I will never like that. And you are also right there are things even worse than this, no question there Edit: "implementing iteration on == would have been too much" is an invalid argument, if anyone had doubts permalink fedilink source parent
[–] marlowe221@lemmy.world 2 points 1 year ago (1 child) It’s false. Different memory addresses, etc. permalink fedilink source parent hideshow 1 child comment replies: [–] Shanmugha@lemmy.world 1 point 1 year ago Like I didn't know 😂 permalink fedilink source parent
[–] phoenixz@lemmy.ca 1 point 1 year ago (3 children) JavaScript sucks but I'll give it this one Arrays are complex structures with multiple values. Just because one looks like the other doesn't make them the same object. It's like taking two new objects form the same class, they look the same but work independently from eachother. I can add a value to one and the other would be unaffected, they'd both still be the same class permalink fedilink source parent hideshow 3 child comments replies: [–] Shanmugha@lemmy.world 1 point 1 year ago* (2 children) And I can't take this one. I did not ask if an object referenced by a is the same object referenced by b, I asked if two empty collections of values are equal. And an empty bag can easily be substituted by another empty bag, there is no class/instance tricky business here. And the fact that in JS arrays are objects is again JS-specific insanity. Still I thank you for sharing your thoughts permalink fedilink source parent hideshow 2 child comments replies: [–] phoenixz@lemmy.ca 2 points 1 year ago (1 child) Well it's what you'd want but not what it does, for one, but for another: comparing scalars is very easy, comparing complex structures is not. To compare one array with another you'd need to iterate over each element, recursively. That JavaScript handles arrays as objects is also not bad, that's just a language feature that you may like or not, not much can go wrong there. The reassignment of "this" or how JS handlesnumber comparison, yeah, that is infuriatingly bad permalink fedilink source parent hideshow 1 child comment replies: [–] Shanmugha@lemmy.world 1 point 1 year ago* (last edited 1 year ago) Yeah. JS is okay with lots of funny (and not fun) type coercions (toString on everything? really?), has no notion of reference as data type, but somehow automatic iteration on array by "==" operator is too much You are right, that's not want I would want from it, it is bad, I will never like that. And you are also right there are things even worse than this, no question there Edit: "implementing iteration on == would have been too much" is an invalid argument, if anyone had doubts permalink fedilink source parent
[–] Shanmugha@lemmy.world 1 point 1 year ago* (2 children) And I can't take this one. I did not ask if an object referenced by a is the same object referenced by b, I asked if two empty collections of values are equal. And an empty bag can easily be substituted by another empty bag, there is no class/instance tricky business here. And the fact that in JS arrays are objects is again JS-specific insanity. Still I thank you for sharing your thoughts permalink fedilink source parent hideshow 2 child comments replies: [–] phoenixz@lemmy.ca 2 points 1 year ago (1 child) Well it's what you'd want but not what it does, for one, but for another: comparing scalars is very easy, comparing complex structures is not. To compare one array with another you'd need to iterate over each element, recursively. That JavaScript handles arrays as objects is also not bad, that's just a language feature that you may like or not, not much can go wrong there. The reassignment of "this" or how JS handlesnumber comparison, yeah, that is infuriatingly bad permalink fedilink source parent hideshow 1 child comment replies: [–] Shanmugha@lemmy.world 1 point 1 year ago* (last edited 1 year ago) Yeah. JS is okay with lots of funny (and not fun) type coercions (toString on everything? really?), has no notion of reference as data type, but somehow automatic iteration on array by "==" operator is too much You are right, that's not want I would want from it, it is bad, I will never like that. And you are also right there are things even worse than this, no question there Edit: "implementing iteration on == would have been too much" is an invalid argument, if anyone had doubts permalink fedilink source parent
[–] phoenixz@lemmy.ca 2 points 1 year ago (1 child) Well it's what you'd want but not what it does, for one, but for another: comparing scalars is very easy, comparing complex structures is not. To compare one array with another you'd need to iterate over each element, recursively. That JavaScript handles arrays as objects is also not bad, that's just a language feature that you may like or not, not much can go wrong there. The reassignment of "this" or how JS handlesnumber comparison, yeah, that is infuriatingly bad permalink fedilink source parent hideshow 1 child comment replies: [–] Shanmugha@lemmy.world 1 point 1 year ago* (last edited 1 year ago) Yeah. JS is okay with lots of funny (and not fun) type coercions (toString on everything? really?), has no notion of reference as data type, but somehow automatic iteration on array by "==" operator is too much You are right, that's not want I would want from it, it is bad, I will never like that. And you are also right there are things even worse than this, no question there Edit: "implementing iteration on == would have been too much" is an invalid argument, if anyone had doubts permalink fedilink source parent
[–] Shanmugha@lemmy.world 1 point 1 year ago* (last edited 1 year ago) Yeah. JS is okay with lots of funny (and not fun) type coercions (toString on everything? really?), has no notion of reference as data type, but somehow automatic iteration on array by "==" operator is too much You are right, that's not want I would want from it, it is bad, I will never like that. And you are also right there are things even worse than this, no question there Edit: "implementing iteration on == would have been too much" is an invalid argument, if anyone had doubts permalink fedilink source parent