JavaScript Array with() Method (new in ES 2023)

preview_player
Показать описание
What's with the new with() method on JavaScript arrays?

with() is new in ECMAScript 2023, also known as ES 14, which is the standard for JavaScript.

In this video, we look at how to replace an element in an array. Using the bracket syntax mutates the original array. Using with() instead creates a new array with the changed element, treating the original array as immutable.

with() is a great choice when working in applications that support immutable patterns such as state management libraries and functional programming techniques.

*Links*

Includes information on setting up Angular to support ES 2023 features.

*Content*
00:00 Array with() method
00:34 Replacing an Element in an Array
02:08 Array with() method is immutable
03:02 with() supported in ES 2023 and TypeScript 5.2
03:59 The with() method and negative indexes
04:30 Chaining with the with() method
05:03 Wrap Up

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
😊About Me
Hey! I'm Deborah Kurata
I'm a software developer and YouTube content creator. I speak at conferences such as VS Live and ng-conf. I write articles for freeCodeCamp. And I'm a Pluralsight author with courses in the top 10 most popular (out of 7,000+) over the past 5 years. For my work in support of software developers, I've been recognized with the Microsoft Most Valuable Professional (MVP) award, and I'm a Google Developer Expert (GDE).

▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
#javascript #with #withmethod #es14 #es2023
Рекомендации по теме
Комментарии
Автор

Any chance for a long video on Angular 17 enhancements? Like a similar course that you have on Pluralsight? Would love to watch that and learn!

dg-cggi
Автор

Hi Deborah, great video as always!
I was wondering: is with() almost the same as toSpliced() with the only difference the fact that you can't optionally select only a part of the array to copy instead of all the elements?

danielabonvini
Автор

That was an excellent summary of .with(). Your teaching style is second to none.
Thank you!
Would you also make videos/books on .NET and Java/ Spring Boot?

fieryscorpion
Автор

They could have chosen an explicit name, why naming it with() instead of replace() 😞

attoumak
Автор

Deborah, please zoom in on your code text. And, more JS videos please.

dee.s.
Автор

Please stop using let 😢😂… you will have all these people coding immutable which is not good unless it’s needed.

Use const

StephenRayner