Expert Developer JavaScript Question:
Download Job Interview Questions and Answers PDF
Explain the unshift() method in JavaScript?
Answer:
This method is functional at the starting of the array, unlike the push(). It adds the desired number of elements to the top of an array. For example -
var name = [ "john" ];
name.unshift( "charlie" );
name.unshift( "joseph", "Jane" );
console.log(name);
The output is shown below:
[" Jane ", " joseph ", " charlie ", " john "]
var name = [ "john" ];
name.unshift( "charlie" );
name.unshift( "joseph", "Jane" );
console.log(name);
The output is shown below:
[" Jane ", " joseph ", " charlie ", " john "]
Download Expert JavaScript Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
What are the various functional components in JavaScript? | What are the decodeURI() and encodeURI()? |