Blogger Information
Blog 16
fans 0
comment 0
visits 9649
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
对象模拟数组
坨坨
Original
469 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>对象模拟数组</title>
  6. </head>
  7. <body>
  8. <script>
  9. function MyArray() {
  10. this.length = arguments.length;
  11. for(var i=0; i<arguments.length; i++) {
  12. this[i] = arguments[i];
  13. }
  14. this.push = function(s) {
  15. this[this.length]=s;
  16. this.length++;
  17. return this.length;
  18. }
  19. this.pop = function() {
  20. var popdata = this[this.length-1];
  21. delete this[this.length-1];
  22. this.length--;
  23. return popdata;
  24. }
  25. }
  26. var arr = new MyArray(11,3,55,88, 99, "abc");
  27. var arr1 = [2,3434,64,12,56,78]
  28. arr1.forEach(function(value){
  29. console.log(value);
  30. // console.log(index);
  31. // console.log(arr1);
  32. arr.push(value)
  33. })
  34. console.log(arr)
  35. // console.log(typeof arr1);
  36. // console.log(arr1);
  37. </script>
  38. </body>
  39. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post