Using the spread operator to append/prepend elements to an array. It also returns the array rather than the length of the array, which I've never found that useful.
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
I am a software development engineer in test for Infosys. My job is officially to write automated tests in Selenium Webdriver. I'm also a web developer as a hobbyest
First time I used Async/Await was a Vue project with a Java Servlet backend. Plopped await in front of the fetch that connected with my back end, and async in front of vue's mounted() method and squealed in delight when my component rendered with my data base information for the first time.
Multiple moments of triumph at once, first use Async/Await, first success with a servlet, and was still new to Vue.JS.
Let's say, you need to sequentially resolve three promises. Callback hell looks like this:
function asyncJob(callback) {
asyncA(xyz, (err, buffer) => {
if (err) { throw err; }
asyncB(buffer, (err, result) => {
if (err) { throw err; }
asyncC(result, (err, response) => {
if (err) { throw err; }
if (response.ok()) { return callback(); }
throw new Error('Could not send result');
});
})
});
}
Now the same with Promises:
const asyncJob = () => asyncA(xyz)
.then((buffer) => asyncB(buffer))
.then((result) => asyncC(result))
.then((response) => {
if (response.ok()) { return Promise.resolve(); }
throw new Error('Could not send result');
});
Reads a lot better, doesn't it? Still, it's pretty terse and has a lot of repetition, so async/await is a big improvement when it comes to reading flow:
const asyncJob = async () => {
const buffer = await asyncA(xyz);
const result = await asyncB(buffer);
const response = await asyncC(result);
if (!response.ok()) {
throw new Error('Could not send result');
}
};
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
.then(...) still takes a callback. So while it reads much more congruently, it's basically still good old callback hell, just in a better suit and with better manners. Async/await is a game changer when it comes to readability of asynchronous code.
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Definitely destructuring, spread, arrow functions, template literals for string interpolation, generators (even if I'm not currently using them), array includes, async/await. Curious to see how async interation works
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
hahahah ok, so if I have to choose one I'm going to say destructuring.
You can live without spread, arrow functions, literals, generators, includes and asnc await.
Destructuring in function arguments makes the code much more readable instead of having either a super long list of parameters or options as an argument.
I am a software development engineer in test for Infosys. My job is officially to write automated tests in Selenium Webdriver. I'm also a web developer as a hobbyest
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
Ooooph tough decision... probably the combination of proper native iterators, the for ... of loop, and generators, which all combine together to amazing effect.
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Full-time web dev; JS lover since 2002; CSS fanatic. #CSSIsAwesome
I try to stay up with new web platform features. Web feature you don't understand? Tell me! I'll write an article!
He/him
They're super cool and can really clean up your code in some cases, especially when you get into async iterators/generators. My second article ever on dev.to was actually about iterators, generators, symbols, for ... of, and how it all fits together!
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
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
11 plus years* active enterprise development experience and a Fine art degree 🎨
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
11 plus years* active enterprise development experience and a Fine art degree 🎨
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Spread, destructuring, arrow functions, async-await - they made me actually see JavaScript for what it is instead of just a browser scripting language 😃 now I'm just waiting for the pipeline operator
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
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
11 plus years* active enterprise development experience and a Fine art degree 🎨
Software dev at Netflix | DC techie | Conference speaker | egghead Instructor | TC39 Educators Committee | Girls Who Code Facilitator | Board game geek | @laurieontech on twitter
Using the spread operator to append/prepend elements to an array. It also returns the array rather than the length of the array, which I've never found that useful.
Spread operator is wonderful. What's crazy to me is how many different ways it can be used. Like arrays vs. objects.
oh man, Object spread is the best thing... maybe I should change my answer 🤔
I wish there could be such an easy way to remove elements from array.
Async/await is so great. No more callback hell ever again.
First time I used Async/Await was a Vue project with a Java Servlet backend. Plopped await in front of the fetch that connected with my back end, and async in front of vue's
mounted()method and squealed in delight when my component rendered with my data base information for the first time.Multiple moments of triumph at once, first use Async/Await, first success with a servlet, and was still new to Vue.JS.
Example?
Let's say, you need to sequentially resolve three promises. Callback hell looks like this:
Now the same with Promises:
Reads a lot better, doesn't it? Still, it's pretty terse and has a lot of repetition, so async/await is a big improvement when it comes to reading flow:
We call the second thenable hell.
I'm a fan of Promise.all as a solution, but I acknowledge async/await is a great option too.
.then(...)still takes a callback. So while it reads much more congruently, it's basically still good old callback hell, just in a better suit and with better manners. Async/await is a game changer when it comes to readability of asynchronous code.Arrow functions. I love the clean, simple syntax for managing functions. We can go from this:
To just this:
There are learning and readability curves here, but it's not bad and I think well worth it.
Always a solid choice!
Definitely destructuring, spread, arrow functions, template literals for string interpolation, generators (even if I'm not currently using them), array includes, async/await. Curious to see how async interation works
You can't have 5 favorites rhymes! Just kidding, love it.
hahahah ok, so if I have to choose one I'm going to say destructuring.
You can live without spread, arrow functions, literals, generators, includes and asnc await.
Destructuring in function arguments makes the code much more readable instead of having either a super long list of parameters or
optionsas an argument.Destructuring FTW
Destructuring
So before ES2015 and destructuring we had this:
or for arrays
Now it's prettier with
or for arrays:
It comes really handy when iterating over
Object.entries, which gives you an array like:[ [key1, value1], [key2, value2] . . . . [keyN, valueN] ]Because you can do this:
Or this
It's nice, like python packing/unpacking:
I mean, sure it can get ugly:
but that goes for anything in programming.
Definitely my favorite!
Ooooph tough decision... probably the combination of proper native iterators, the
for ... ofloop, and generators, which all combine together to amazing effect.I watched an awesome talk on generators last week. Not something I’d used before!
They're super cool and can really clean up your code in some cases, especially when you get into async iterators/generators. My second article ever on dev.to was actually about iterators, generators, symbols,
for ... of, and how it all fits together!The JavaScript Iteration Protocols and How They Fit In
Ken Bellows ・ 12 min read
Oh awesome. Will check it out!
How about Proxies and Map/Sets ?
Ooh, that's a new answer!
Yah trying to mix it up 😂
But I said metaprogramming so that is the category that proxies sit under .. anyway here's how to break JavaScript with proxies.
Class syntax.
I am looking forward to the up and coming class field syntax to fix the broken syntax that is class syntax. Syntax 😂
Oh yes, definitely an awesome addition.
Spread, destructuring, arrow functions, async-await - they made me actually see JavaScript for what it is instead of just a browser scripting language 😃 now I'm just waiting for the pipeline operator
native support for import/export 😂 and certainly those bacticks
and
The spread operator and I are very good friends.
Understandably :)
Metaprogramming for sure! It's probably not healthy to have that much power though, I still love it.
Haha, with great power...
The easy arrow function syntax to make small function really short and less cramy like eg:
instead of old pre ES-6 syntax