Use the modulo operator? Nah. Need to import the isEven library and a ton of other unnecessary sub-50 LOC libraries “maintained” by a single dev to make their CV look more impressive. /s
JavaScript is NOT fine, it’s … I’m really trying to think of a word that will convey the shit that it is without triggering half the people on Lemmy into an aneurysm, but I can’t find it.
JavaScript is by far the worst. I’ve been working with JavaScript for the past 6 days and I want to hang myself, it’d be a better fate than continuing
Yeah, I had some webpages archived and tried to use javascript to clean them up, but I ended up parsing it as xml through Powershell instead. I’ve done something with Python and BeautifulSoup too, a long time ago. Both much easier than JS, but somehow JS is designed to work with web pages? Make it make sense.
PHP was shit 25 years ago (like everything else back then) and I never bothered to look at it ever again but to this day I keep shitting on it because reasons
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
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
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
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
The joke is always Javascript
JavaScript itself is fine. The problem is developers who import a library to add two numbers.
Excuse me, but it’s industry practice to always use PlusJs.
Its just annoying that it has its own dependency on MinusJs.
And MinusJs depends on AngularJs and VueJs for some reason, but that’s just the cost of doing business!
https://www.npmjs.com/package/is-even?activeTab=dependencies
Maybe we wouldn’t need external libraries to do basic things if JavaScript had a standard library
What is this crazy talk??
The thing you want from jQuery was added to all browsers in 2018.
I’m currently on a crusade against lodash where I work.
I dunno. If it makes everything Array-like act like a goddamn Array, I’m tempted to start using it.
‘What do you mean you can’t .map a Set? It’s iterable! Figure it out!’
You can though?
mySet.values().map(mappingFunc)
will create a new iterator transformed by the mapping function.Use the modulo operator? Nah. Need to import the isEven library and a ton of other unnecessary sub-50 LOC libraries “maintained” by a single dev to make their CV look more impressive. /s
Oh Hells no.
JavaScript is NOT fine, it’s … I’m really trying to think of a word that will convey the shit that it is without triggering half the people on Lemmy into an aneurysm, but I can’t find it.
JavaScript is by far the worst. I’ve been working with JavaScript for the past 6 days and I want to hang myself, it’d be a better fate than continuing
6 Whole Days!
Try 25 years. And it still surprises me.
Yeah, I had some webpages archived and tried to use javascript to clean them up, but I ended up parsing it as xml through Powershell instead. I’ve done something with Python and BeautifulSoup too, a long time ago. Both much easier than JS, but somehow JS is designed to work with web pages? Make it make sense.
PHP
You
console.log([] == [])
It’s false. Different memory addresses, etc.
Like I didn’t know 😂
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
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
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
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
Or ship a browser to run a script.