Created
December 27, 2021 06:49
-
-
Save hoyangtsai/97f1866dd02978976c14eb80cb0652f6 to your computer and use it in GitHub Desktop.
Add an element ahead of array #snippet #array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use ES6 unshift | |
TheArray.unshift(TheNewElement); | |
// use splice | |
TheArray.splice(0, 0, TheNewElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answer found here