Array Methods in Javascript Explained!



Code :

const arr = [];
console.log(arr);
//this will give you nothing because you not entered any elements in array so to
// add elements in array we need push function 
arr.push(2);
console.log(arr);
// this will show 2

because we just added 2 in the array 
To Remove elements from the array we will need to use pop() function which will remove the elements in array.

arr.pop();
//this will remove 2 from an array .


VIDEO EXPLANATION


Comments