Explain pushing into array [duplicate]

push is a method which pushes the data at the end of the existing array without having to know the index of your array. so if your data is not for a specific index and can be at the end in stack, just use the push method. the output would be-

old val of array1 : ['ab','bc', 'ca']

array1.push('cz');

new value of array1 : ['ab','bc', 'ca', 'cz']

Leave a Comment