JavaScript array push
The JavaScript push method can add a new array element to the back of the array object and return the new array length. The new elements are added sequentially at the end of the array. If you want to add it to the front of the array Elements should be processed using the JavaScript unshift method. The JavaScript array push method is also a built-in JavaScript function, which can be called at any time without additional installation, and almost all mainstream browsers support the JavaScript push method.
JavaScript array push basic syntax
array.push('item1','item2','item3','item4', ...)
The array object is followed by push to add elements to the back of the array. Item is a necessary item. At least one is required. There is no special restriction at most. Although the JavaScript array push technique does not limit the array elements that can be added Quantity, but you should also try to avoid endless push and cause the browser to be unable to process.
JavaScript array push example
var Arr = ['Father','Mother','Brother'];
document.write('Array content:'+Arr+'<br>');
document.write(' Array length:'+Arr.length+'<p>');
Arr.push('Sister');
document.write('Array content:'+Arr+'<br>');
document.write('Array length: '+Arr.length+'<p>');
</script>
Array length: 3
Array content: Father,Mother,Brother,Sister
Array length: 4
Post a Comment
0 Comments