Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>对象模拟数组</title>
</head>
<body>
<script>
function MyArray() {
this.length = arguments.length;
for(var i=0; i<arguments.length; i++) {
this[i] = arguments[i];
}
this.push = function(s) {
this[this.length]=s;
this.length++;
return this.length;
}
this.pop = function() {
var popdata = this[this.length-1];
delete this[this.length-1];
this.length--;
return popdata;
}
}
var arr = new MyArray(11,3,55,88, 99, "abc");
var arr1 = [2,3434,64,12,56,78]
arr1.forEach(function(value){
console.log(value);
// console.log(index);
// console.log(arr1);
arr.push(value)
})
console.log(arr)
// console.log(typeof arr1);
// console.log(arr1);
</script>
</body>
</html>