The .toSpliced() method - Unleash the Power of JavaScript Updates
Vložit
- čas přidán 9. 07. 2024
- Another awesome addition to JavaScript in ES14 (ECMAScript 2023), we get the toSpliced method. Yes, pretty close to toReveresed and toSorted! It works just like .splice() but instead of mutating the array and returning the deleted elements, it returns the array after deletion and insertion. This is a quick but worthwhile update. Don't forget to hit subscribe and get all the updates to JavaScript!
Code: github.com/robertbunch/es-next
History of ECMAScript/JavaScript (long) - • Visual Timeline of Jav...
History of ECMAScript/JavaScript (shorter) - • Visual Timeline of Jav...
0:00 - Intro
0:33 - toSpliced() and splice() docs
2:53 - Code example
4:51 - Other notes from the docs (sparse, generic) - Věda a technologie
Good one sir! Thank you
Thanks! These are such great additions. Whether we use them or not, they bring JavaScript architecture into better focus.
I don't know, but Array.splice() method is confusing sometimes because it has dual functionality (delete and insert)
I wish JS has it's dedicated Array.insert() method.
Thanks and keep it up Rob!
Yes, it is strangely lacking. I get that it might difficult to implement in C or Java after the fact, but for a language that is incredibly flexible in how it manages array, it's odd that there's no option to run just one of the two, very common, actions. Even after all these years I have to double check sometimes, "which comes first, delete or insert..." Unnecessarily confusing.
@@robertbunch-dev Same feeling 🤦♂😁