Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

unshift javascript

/*The unshift() adds method elements to the beginning, and push() method 
adds elements to the end of an array.*/
let twentyThree = 'XXIII';
let romanNumerals = ['XXI', 'XXII'];

romanNumerals.unshift('XIX', 'XX');
// now equals ['XIX', 'XX', 'XXI', 'XXII']

romanNumerals.push(twentyThree);
// now equals ['XIX', 'XX', 'XXI', 'XXII', 'XXIII']
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #unshift #javascript
ADD COMMENT
Topic
Name
9+8 =