Jquery SEND TO END OF ARRAY 1

Jquery SEND TO END OF ARRAY

var colors = ['red','blue','green'];

/*// PUSH TO FRONT OF ARRAY
---------------------------*/
colors.push('yellow');
// colors = ['red', 'blue', 'green', 'yellow']

Here is what the above code is Doing:
1. We create an array called colors.
2. We use the push() method to add the string ‘yellow’ to the end of the array.
3. We print the array to the console.

Similar Posts