Explain the unshift() method in JavaScript?
Submitted by: AdministratorThis 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 "]
Submitted by:
var name = [ "john" ];
name.unshift( "charlie" );
name.unshift( "joseph", "Jane" );
console.log(name);
The output is shown below:
[" Jane ", " joseph ", " charlie ", " john "]
Submitted by:
Read Online Expert Developer JavaScript Job Interview Questions And Answers
Top Expert Developer JavaScript Questions
☺ | Mention what is the disadvantage of using innerHTML in JavaScript? |
☺ | Which keyword is used to print the text in the screen? |
☺ | Why it is not advised to use innerHTML in JavaScript? |
☺ | Explain the concept of unobtrusive JavaScript? |
☺ | How are JavaScript and ECMA Script related? |
Top Scripting language Categories
☺ | AngularJS Interview Questions. |
☺ | Ext-JS Interview Questions. |
☺ | Dojo Interview Questions. |
☺ | Expert Developer JavaScript Interview Questions. |
☺ | jQuery Mobile Interview Questions. |