So while the operator versions have brevity on their side I think they lack clarity, especially for those who are encountering this type of usage for the very first time. And in JavaScript the operators don't fit with the way type coercion is designed to work.
On a personal level I've never understood Haskell's obsession with "operators". "operators" don't add anything if they do exactly the same work as a function with one or two arguments - i.e. just stick to a function. The case is different if and only if not all arguments of the operator expression are evaluated, e.g. the conditional operator.
This adheres to our general principle - we do not provide built-in mechanisms, we provide primitives with which mechanisms can be built
(Erlang provides the primitives, OTP implements the mechanisms)
i.e. let the language only supply the essential functionality needed to build everything else.
In the case of JavaScript it's a bit different as you are trying to delegate as much work as possible to the browser - the runtime can accomplish many natively implemented tasks much faster.
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
result = Array.from({ length: 2 }, (_v) => 'Hello world');
The callback is actually slower then map new Array(n). Completely irrelevant off topic stuff right here 😂
I take the point 💯 functional is clear and my thoughts ... Are usually a jumbled mess, non the less apparently Python can multiply a string so it must be a good idea, right? 🤷♂️
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
So while the operator versions have brevity on their side I think they lack clarity, especially for those who are encountering this type of usage for the very first time. And in JavaScript the operators don't fit with the way type coercion is designed to work.
The solution to many problems is simply:
On a personal level I've never understood Haskell's obsession with "operators". "operators" don't add anything if they do exactly the same work as a function with one or two arguments - i.e. just stick to a function. The case is different if and only if not all arguments of the operator expression are evaluated, e.g. the conditional operator.
In many ways I prefer Erlang's philosophy:
(Erlang provides the primitives, OTP implements the mechanisms)
i.e. let the language only supply the essential functionality needed to build everything else.
In the case of JavaScript it's a bit different as you are trying to delegate as much work as possible to the browser - the runtime can accomplish many natively implemented tasks much faster.
So before I start:
result = Array.from({ length: 2 }, (_v) => 'Hello world');
The callback is actually slower then map new Array(n). Completely irrelevant off topic stuff right here 😂
I take the point 💯 functional is clear and my thoughts ... Are usually a jumbled mess, non the less apparently Python can multiply a string so it must be a good idea, right? 🤷♂️