Every year, ECMAScript releases new features in JavaScript. These features either build on existing capabilities or add to them. I skimmed through Olivia Gibson and Darren Jones’ article on 5 Exciting New JavaScript Features in 2024, and one new feature that caught my eye amongst the 5 mentioned was the “Pipe” operator.
The Pipe operator allows you to connect a value/result from one function to another. Essentially this looks like a better and easier-to-read method for method chaining in JavaScript:
If you don’t know, this is how method chaining looks like in JavaScript:
let fav_num = 777;
fav_num.toFixed(3).valueOf()
Basically, it is using the result of one method, chaining it with another one. Using the pipe operator, you would have this instead:
let fav_num = 777;
fav_num |> toFixed(3) |> valueOf()
You do have more features in the blog such as the Temporal object, Records and Tuples, and a bunch more updates on JavaScript so do check out their article!
Thank you for reading and I hope to see you in the next one.