Earlier quoted context omitted.
You don't need to parse when getting data, the fetch API does that for you automatically. const res = await fetch(url); const data = await res.json(); For posting you do need JSON.stringify(data), but I never thought of it as painful, just a single line.
> fetch API does that for you automatically It does not do it automatically. Even in your example, you call `Response.json()` to do the parsing. If you change that to `Response.text()` it will be text instead. If you don't include the `.json()` call, nothing will be parsed from the body.
New Features in ES2019
51–60 of 123 posts
Re: New Features in ES2019
#52How are these used on a browser? Do you have to wait for browsers to update? It's something I don't understand
So this is basically a fantasy what javascript could be no different than any other alt-js languages .
Re: New Features in ES2019
#53Earlier quoted context omitted.
> fetch API does that for you automatically It does not do it automatically. Even in your example, you call `Response.json()` to do the parsing. If you change that to `Response.text()` it will be text instead. If you don't include the `.json()` call, nothing will be parsed from the body.
I know how it works :) Since it's part of the API getting a response object is pretty effortless, which is a better word than automatic, agree.
Re: New Features in ES2019
#54Trying to retroactively fixing bugs in code that did not follow the standard is not a good idea IMHO.
Re: New Features in ES2019
#55I love Javascript and TypeScript, but with all the technologies gravitating around JS, the setup for a project gets clunkier and clunkier. But overall, loving the direction JS is taking.
Re: New Features in ES2019
#56How are these used on a browser? Do you have to wait for browsers to update? It's something I don't understand
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re: New Features in ES2019
#57Earlier quoted context omitted.
Wow, who came up with that idea? And people say Haskell is hard to learn...
Weak types. When neither the function nor the parameters have hard types, you have to create heuristics. There could be a test for numbers there, but it would also be surprising because at the older days people expected "10" and 10 to behave the same.
[1, 10, 2].sort((a,b) => a > b ? 1 : -1)
// -> [1, 2, 10]
is something like // [1, 10, 2].sort((a,b) => a.toString() > b.toString() ? 1 : -1)
// -> [1, 10, 2]
because someone thought that it was "best" to cast stuff to string in case whatever you put in the container didn't implement comparison.Re: New Features in ES2019
#58Demanding a stable Array.sort is surprising. I find it questionable, as it implies a performance trade-off. Why not add a new stableSort function? Trying to retroactively fixing bugs in code that did not follow the standard is not a good idea IMHO.
It was actually proposed by the v8 / chrome people (https://v8.dev/features/stable-sort) after they'd finally come around to implement one of the oldest v8 feature requests: https://bugs.chromium.org/p/v8/issues/detail?id=90
And stable does make for a better default than unstable: it offers stronger guarantees and more reliable behaviour. That's doubly important because by and large developers work to the implementation not the spec. And it's unlikely you'll ever change that.
The last one to switch was Chakra (Edge), and that one was weird as it used a stable sort up to 512 elements, and unstable above.
Funnily enough, Mozilla had originally switched to a stable sort because MSIE used a stable sort: https://bugzilla.mozilla.org/show_bug.cgi?id=224128
Re: New Features in ES2019
#59I wonder what kind of shenanigans you could do with Function.toString(). It'd be even better if they had Function.toAST().
Re: New Features in ES2019
#60Earlier quoted context omitted.
How so? Were these eval()ed by Angular? I don't follow what it would use function strings for determining missing - presumably - polyfills that you couldn't do in better ways.
In angular 1, if you had a function on the form myApp.controller('MyCtrl', function($myCoolService) { //... }); Angular would see that you are looking for a parameter named myCoolService, see if it already has it, and then inject it when calling your controller. This of course broke in various ways with minification when the parameter names were mangled. So one had the opportunity to use "array syntax", requesting a…