What is unshift method in javascript?

 unshift method array javascript:

unshift() add elements from the first index and the Result will be returned with a new index.

 

unshift example in javascript:

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

 

console.log(colors.unshift("Black", "Orange"));

// 5

 

console.log(colors);

// Array ["Black", "Orange", "Red", "Green", "blue"]




No comments:

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

Copyright Reserved to Anything Learn. Powered by Blogger.