Earlier quoted context omitted.
What would some common/helpful use cases be?
I often use Object.entries so that I can use Array.filter/map/foreach on an object, but then I need to use Array.reduce to hack it back into an object. Object.fromEntries solves this.
What’s New in ES2019
341–350 of 411 posts
Re: What’s New in ES2019
#342Earlier quoted context omitted.
TypeScript is becoming the de facto type annotations proposal.
Let me know when (type inference of) partial function application and object literals are easy in Typescript and I’ll consider it.
Re: What’s New in ES2019
#343Earlier quoted context omitted.
From my perspective, it is less about what we can use in the browser without transpilation, but where the js ecosystem is heading. I personally only want to write JS that is in spec because in 5 years something like decorators might not be a thing. Basically when I'm figuring out what language features I care about, I'm thinking about how hard it will be for other engineers to work on the codebase. Things that are no…
> Basically when I'm figuring out what language features I care about, I'm thinking about how hard it will be for other engineers to work on the codebase. Things that are not in spec are going to be less familiar and more time to learn. I agree, this is super important. My inclination whenever I did into a JS project has been to use lodash/underscore everywhere for everything, assuming that it is popular enough that…
Re: What’s New in ES2019
#344Re: What’s New in ES2019
#345Honest question, not meant to be inflammatory. If we still need to target es5 4 years later, and transpilation is standard practice, why bother? Is the evolution of JS not directed in practice by the authors of Babel and Typescript? If no one can confidently ship this stuff for years after, what’s the incentive to even bother thinking about what is official vs a Babel supported proposal. I like the idea of idiomatic…
I'm sure there are plenty of build systems out there that still indiscriminately turn things into ES5, because "that's how we wrote it years ago and it still works", but anyone who actually cares about performance will think twice before using babel today to turn nice, clean, concise modern code into incredibly verbose and shimmed legacy code, and will certainly think twice before serving ES5 code to users on a modern browser.
Re: What’s New in ES2019
#346Earlier quoted context omitted.
I dig it too, but you could previously flatten an array with concat, and the spread operator. [].concat(...array) Lodash wasn't necessary.
No this is not an alternative, it will fail if the array is too large, as you will exceed the maximum number of arguments a function will accept (which is implementation defined). In general the spread operator should only be used for forwarding arguments not for array operations.
Not quite. You should also use the spread operator when you are spreading an iterable into an array:
const unique = [...new Set(arr)];Re: What’s New in ES2019
#347Earlier quoted context omitted.
The biggest issue I've seen with these is that at some point they do break and then you need a knowledgeable person to fix it. The pipeline is basically a black box unless you possess the knowledge of how all the parts work and interact with each other.
I dunno how to put this in a non-controversial way, but...at some point, I switched from thinking a desirable, throw-the-money-at-them developer is somebody who writes a lot of code to somebody who understands things and is capable of understanding new ones when they arise. I'm not saying that to excuse thrash . Thrash is bad. But like..."oh, at some point you'll have to have somebody who actually understands how the…
Some of us won't let go of the crazy dream that things should be simpler. I want this not because I'm lazy or because I don't understand them but because - dammit - things should be simpler.
Re: What’s New in ES2019
#348Earlier quoted context omitted.
I wonder if there are enough use-cases for .flat to not default to Infinity. It's also confusing that `arr.flatMap()` is not equivalent to `arr.map().flat()`, but to `arr.map.flat(Infinity)`
According to MDN `arr.flatMap()` is indeed equivalent to `arr.map().flat()` (without the Infinity). [1] Testing in the Chrome Devtools it also seems to be the case: x = [[[1, 2]], [[2, 3]], [[3, 4]]] x.flatMap(x=>x) output: [[1,2], [2,3], [3,4]] x.map(x=>x).flat() output: [[1,2], [2,3], [3,4]] x.map(x=>x).flat(Infinity) output: [1, 2, 2, 3, 3, 4] [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... >…
Re: What’s New in ES2019
#349Honest question, not meant to be inflammatory. If we still need to target es5 4 years later, and transpilation is standard practice, why bother? Is the evolution of JS not directed in practice by the authors of Babel and Typescript? If no one can confidently ship this stuff for years after, what’s the incentive to even bother thinking about what is official vs a Babel supported proposal. I like the idea of idiomatic…
Right now, for example, the apps I'm working on require at least async/await support as a minimum test.
Re: What’s New in ES2019
#350Earlier quoted context omitted.
> It's popular to be sure but handwritten javascript is not that rare nowadays, is it? Long time front end developer here. In the last couple of years I can't recall seeing even a single project without a build pipeline (not that they don't exist, I just haven't encountered them at my day job, first or third party).
I don't understand what is so appealing about not having a build pipeline for JavaScript, other than the ability to very quickly test and learn things directly in the browser, which of course anyone can still do. For anything remotely important, you're almost certainly going to already want a build pipeline to do things like concatenating/minifying code, running tests, and deploying. Adding a transpilation step to ex…
The payload to fill promises, regenerator and async are huge, and without them, my payload is significantly smaller. for preset-env...
{
loose: true,
modules: false,
useBuiltIns: 'usage',
corejs: 3,
targets: {
browsers: ['edge 15', 'safari 10.1', 'chrome 58', 'firefox 52', 'ios 10.3'],
},
exclude: ['transform-async-to-generator', 'transform-regenerator'],
},
from here, I only need the features not part of stage 4 that I want to add. I have the following in a test script... try {
eval('(function() { async _ => _; })();');
if (typeof fetch === 'undefined') throw new Error('no fetch');
} catch (e) {
window.location.replace('/auth/legacy.html');
}
With async functions, and fetch api available, you get a LOT in the box.