After Years of Waiting, This JavaScript Feature Finally Arrives

Posted by






I’ve Waited YEARS For This JavaScript Feature…

I’ve Waited YEARS For This JavaScript Feature…

As a developer, there are certain features and updates that we eagerly anticipate. For me, one such feature was the introduction of async/await in JavaScript. I had waited years for this functionality to be added to the language, and when it finally arrived, it completely revolutionized my approach to writing asynchronous code.

Prior to the introduction of async/await, handling asynchronous operations in JavaScript often involved callbacks or promises, which could lead to deeply nested and hard-to-read code. With async/await, however, writing asynchronous code became much more straightforward and intuitive. The syntax allows for the use of the “await” keyword to pause execution until a promise is resolved, making it easier to write and understand asynchronous code.

One of the biggest benefits of async/await is its ability to make asynchronous code look and behave more like synchronous code. This not only makes the code easier to read and maintain, but it also reduces the likelihood of errors and bugs. As a result, I found myself spending less time debugging and more time writing new features and functionality in my applications.

Another aspect of async/await that I had waited years for is its error handling capabilities. With traditional async code, error handling often involved nested try/catch blocks or chaining .catch() methods onto promises. This could quickly become cumbersome and difficult to manage. With async/await, error handling is much simpler and more in line with synchronous code, making it easier to handle and propagate errors throughout the application.

In conclusion, the introduction of async/await in JavaScript was a game-changer for me and many other developers. It has made writing and maintaining asynchronous code much more manageable and enjoyable. I’ve waited years for this feature, and it definitely did not disappoint. I look forward to seeing what other improvements and updates the JavaScript language will bring in the future.


0 0 votes
Article Rating
35 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Russell Dempsey
7 months ago

I like most of this video but lets please stop promoting code golf, outside of code golf, just for code golfs sake. (i.e. One line of code is rarely better than more lines of code unless the code is cleaner, more maintainable, or more performant)

Soul Evans
7 months ago

Apart from that I cannot figure out how to put it in global scope here is a solution right now in typescript.

type PFunc<In, Out> = (val: In) => Out;

function next<In, PrevOut>(fn: PFunc<In, PrevOut>, input: In) {
return {
pipe: <NextOut>(nextFn: PFunc<PrevOut, NextOut>) => next(nextFn, fn(input)),
out: () => fn(input),
};
}

function to<In>(val: In) {
return {
pipe: <Out>(fn: PFunc<In, Out>) => next(fn, val),
};
}

const output = to(1)
.pipe((x) => x * 10)
.pipe((x) => Array(x).fill(null).join(`${x}`))
.pipe((x) => x.length)
.out();

console.log(output);

const magic = to({ x: 10, type: 'foo' })
.pipe((obj) => obj.x)
.pipe((x) => x.toFixed(10))
.pipe(Object.values)
.out();
console.log(magic);

Austin Miller
7 months ago

Oooh man this would be amazing. I hope this goes through.

Tom Theisen
7 months ago

Regular brain: Assume ^ is the exponent operator like a regular human.

Big brain: Know what the exponent operator is.

Galaxy brain: Boost engagement by pretending that ^ is the exponent operator.

m k
m k
7 months ago

the fuck?

Damo
7 months ago

anddddddddd still waiting

Geeksy
7 months ago

Great! Used in Elixir which is a great language

Thomas Synths
7 months ago

This is rather nice. Would be cool if Haskell had that syntax sugar (without resorting to quasi-quotation).

Nicolas Silva A.
7 months ago

is this like then(res =>) ??

Patrick Smith
7 months ago

Loved this when i encountered it in Elixir.

Rendxn
7 months ago

Very similar to R's Tidyverse pipes…

Prakhar Mathur
7 months ago

yes please do make more videos like this. We need them!

I saw your first video yesterday and immediately subscribed.
We need more videos that relate to the real life scenarios that developers face, not just tutorials.

great work man !

Nicolas Antonelli
7 months ago

Hmm… I really like this operator. But I don't like Tailwind xD

Charlike Mike Reagent
7 months ago

Ramdajs is so small, fun and cool, that it even looks better than the native.

I was hyped before years, but I'm against it now.

P S
P S
7 months ago

I use compose and pipe everyday, and the other devs are like WTF??? I keep telling them to embrace/learn declarative and functional programming because it is the future!

Tomas Jansson
7 months ago

Would it be possible to write x |> addTwo |> square? That’s how I like to do it in F#.

吉井雄太朗
7 months ago

How would you use modulo operator though?

Janjac
7 months ago

If this comes, im only scared of refactoring the codebases

Felype Rennan
7 months ago

2:19 "and we'll also be able to break this into a new line"

Javascript return doesn't usually do that tho, I hope we will really be able to do that. It would be kinda hilarious if implicit statement termination remains the same as they implement this operator

Borys Lebeda
7 months ago

Was it JavaScript or TypeScript?
And how long will it take to have it in node.js, browsers and stuff like prettier