'Array.map' takes a callback with three parameters: value, index, and self. '[].map(parseInt)' using the index as the radix is exactly what the code says to do, not some "bad design" or whatever. The result is the programmer's fault.
C#'s 'Select' has an overload that passes the element index to the callback, so if you directly passed a function that takes a second ('int') parameter like in the JavaScript example, you'd get the same behavior.
This is neither unintuitive nor unique to JavaScript. It's probably not even uncommon. As a developer, you need to understand how the language works before blaming it for your own mistakes.
I have a decade of professional experience using JavaScript and this has literally never been an issue for me or anyone I have ever worked with. It's purely a made-up problem that people who simply dislike JavaScript pretend is even remotely valid.
you don't understand the point: Javascript should not let you call a function with less parameters (except in the case of default parameters or in a language with curring
It's not calling a function with fewer parameters (although that is also possible to do). It's just passing parameters that the programmer is free to ignore. When mapping an array, you do not always need all three parameters. It's very convenient and useful to be able to pass functions that only take the item, for example.
JavaScript simply isn't a strongly-typed language that checks these things. That is completely valid design choice whether you agree with it or not. It can be extremely useful not to be restricted by strict typing.
Regardless of the programming language one uses they should accept that they each have their own syntaxes and standard library. There is nothing wrong with parseInt, it's very well documented and the additional parameters are not gotchas if you use your eyes and actually read.
I've spent 3 years professionally programming in Python and 4 at a TypeScript house. I was also doing plenty of JavaScript at both places for our web apps. Both languages have their pros and cons, and most of the warts people bring up with JS hardly come up in day-to-day development.
Python isn't without its faults too, though they're less often with the syntax and more with the standard library (urllib is gross) and performance. Working with asynchronous code is much more of a pleasure in JavaScript.
How much JavaScript or even TypeScript have you used to have such strong opinions on the matter? If your answer is, "I don't use it because it sucks" then you really have nothing to contribute to any discussion on the matter.
Okay, you're not denying that you haven't used it. That's fine, but then stop acting like you have a knowledgeable opinion on the language.
The point is about language itself not libraries.
A language's standard library is typically treated as part of the language by its users, but if you want to draw a distinction to better serve your baseless point then go for it. That includes things such as parseInt by the way, which you seem very opinionated about.
Okay, you're not denying that you haven't used it. That's fine, but then stop acting like you have a knowledgeable opinion on the language.
I've use it for some years . And I am force to use it right now.
And this is not a good argument. You don't need to use everything extensively to know if something is bad. It depends of the context.
For example I didn't wrote single line in Python, Java, Scala before I've had to be productive from the first days. But I knew the languages principal characteristics : dynamic/static, imperative/functional, single dispatch, etc.
There's nothing wrong with parseInt. There is something wrong with map blithely doing slightly different things based on the number of arguments that the function passed in takes. Javascript's map should be three different functions -- map, mapWithIndex, and mapWithIndexAndArray (though I'm not sold on the names).
0
u/[deleted] Sep 29 '23
[deleted]