are arrays mutable in javascript code example
Example: mutable array methods in javascript
var aData = [];
function Person(firstname, lastname) {
this.firstname = firstname;
this.lastname = lastname;
this.fullname = function() {
return (this.firstname + " " + this.lastname);
};
}
aData[aData.length] = new Person("Java", "Script");
aData.push(new Person("Jhon", "Doe"));
aData.push(new Person("Anna", "Smith"));
aData.push(new Person("Black", "Pearl"));
aData[aData.length] = new Person("stack", "overflow");
for (var i in aData) {
alert(aData[i].fullname());
}
var jsonString = JSON.stringify(aData);
document.write(jsonString);