how to add/insert value in array using javascript?

Here  I am going to discuss regarding how to add/insert value in array using javascript? and What is the use of Push method in Javascript?. It is very simple in Javascript. The push() method adds new items to the end of an array, and returns the new length.push method is intentionally generic. This method can be called to objects resembling arrays. The push method relies on a length property to determine where to start inserting the given values. If the length property cannot be converted into a number, the index used is 0. This includes the possibility of length being non-existent, in which case length will also be created.

example.

function Dotnetstock()
{
var arr = new Array();
arr.push('Dotnetstock');
arr.push('.com');
}

Leave a Reply

Your email address will not be published. Required fields are marked *