批改状态:合格
老师批语:
<!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>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号