What is shift method in javascript?

Javascript array shift method:

shift() remove element from the first index. Result will be return with new indexing.

shift() example:

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

const firstColors = colors.shift();

// Array ["Green", "blue"]

// "Red"

Note: pop() remove element from the last index. 

No comments:

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

Copyright Reserved to Anything Learn. Powered by Blogger.