In this tutorial learn how to append something(string/number/value) to an array, can append value in array using push() function,
You can append more than one value to an array in a single call use the push() function
// initialize array
var arr = [
"Jack",
"Taylor",
"Jhone"
];
// append new value to the array
arr.push("Huge");
console.log(arr);
You can append more than one value to an array in a single call use the push() function
// initialize array
var arr = ["Student", "Teacher", "Principal", "Mam"];
// append multiple values to the array
arr.push("Math Teacher", "IT Teacher");
// display all values
for (var i = 0; i < arr.length; i++) {
console.log(arr[i]);
}
No comments:
Post a Comment