What is push method in javascript?

 Javascript array push method:

push(): means it's add value one or multiple in the our array from the last index and return with new index.

Javascript push() example:

const colors = ['Red', 'Green', 'blue'];

const colorCount = colors.push('Black');
// expected output: 4
// ["Red", "Green", "blue", "Black"]

colors.push('Orange', 'White', 'Coffee');
// ["Red", "Green", "blue", "Black", "Orange", "White", "Coffee"]

No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.