Why did they create a flatMap method? What is wrong with .map(...).flat()? Can they improve the performance by combining it that much?
I personally feel flatMap is a much more used method than flat, so if you want to remove one, I would remove flat.
41–50 of 411 posts
Why did they create a flatMap method? What is wrong with .map(...).flat()? Can they improve the performance by combining it that much?
I personally feel flatMap is a much more used method than flat, so if you want to remove one, I would remove flat.
Earlier quoted context omitted.
What’s wrong with var a = ...; a = a.project(); a = debug(a); a = a.eject();
That can’t show the programmer’s intent whether it is mutation (e.g. a = a + someNum) verses defining a new variable with different types (but has a similar meaning so has a same name) (e.g. someKindOfData = [...someKindOfData]) Rust allows this, and it really clears codes up. I don’t have to make up different identifiers for same data but different representations. (e.g. I would do the above code in JS as... someKin…
That Function.prototype.toString change is probably going to break some Angular.js code who relies on scanning function argument names for dependency injection.
That Function.prototype.toString change is probably going to break some Angular.js code who relies on scanning function argument names for dependency injection.
It seems like an unnecessary change - if the source needs to be accessed then get the source file.
Why did they create a flatMap method? What is wrong with .map(...).flat()? Can they improve the performance by combining it that much?
You'll find equivalents in all the JS utility libraries and most functional programming language standard libraries (and languages like Ruby with functional-ish subsets), so there's a lot of evidence that people who write code in that style like to have such a function available.
It's great to see JS getting some of the features of better planned languages. But I'm still very nervous about some of the stuff mentioned here with regard to mutation. Taking Rust and Clojure as references, you always know for sure whether or not a call to e.g. `flat` will result in a mutation. In JS, because of past experience, I'd never be completely confident that I wasn't mutating something by mistake. I don't…
I still don't understand why neither JSs var or let allow you to redefine the variable with the same name. I makes chaining things while debugging so much harder: let a = a.project(); let a = debug(a); let a = a.eject(); vs let a1 = a.project(); let a1d = debug(a1); let a2 = a1d.eject();
Given that JS doesn't restrict the type of a declaration you can just assign a new value to it, place it in a small scope or use a chain.
That’s a surprisingly small amount of change. I’ll leave it to others to determine if that’s a good or bad thing.
Clojure too didn't change a lot. In these years of 'disruption' it feels odd. But it may just be that we forgot stability and maturity.
That’s a surprisingly small amount of change. I’ll leave it to others to determine if that’s a good or bad thing.
Technically most of this is not even language changes but simple changes to the standard apis. E.g. flatMap is something I've missed and worked around by implementing it myself a few times. Not a big deal and nice that they added it. In any case, I use typescript by default now and have converted most of the code I care about at this point. I think most of this improves typescript as well so; overall a good thing.
How much of ES5.5+ was guided by jQuery?