What is Push() method in JavaScript?
Submitted by: Administrator► The push() method is used to append one or more elements to the end of an array.
► For example :
var fruits = [ "apple" ];
fruits.push( "banana" );
fruits.push( "mango", "strawberry" );
console.log(fruits);
► We get the following console output :
["apple ", "banana ", "mango ", "strawberry "]
► Using Push() method we can also append multiple elements by passing multiple arguments.
► The elements will be appended in the order of they are inserted i.e. left to right.
Submitted by:
► For example :
var fruits = [ "apple" ];
fruits.push( "banana" );
fruits.push( "mango", "strawberry" );
console.log(fruits);
► We get the following console output :
["apple ", "banana ", "mango ", "strawberry "]
► Using Push() method we can also append multiple elements by passing multiple arguments.
► The elements will be appended in the order of they are inserted i.e. left to right.
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. |