pop1.js 1002 B

12345678910111213141516171819202122232425262728293031
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. function write(v) { WScript.Echo(v); }
  6. var n = 5;
  7. function InitObject(obj) {
  8. for (var i=0; i<n; i++) {
  9. obj[i] = i * i + 1;
  10. }
  11. obj.length = n;
  12. return obj;
  13. }
  14. function TestPop(obj) {
  15. write(">>> Start pop test for object: " + obj);
  16. for (var i=0; i<n+2; i++) {
  17. var x = Array.prototype.pop.call(obj);
  18. write(i + " iteration. Poped:" + x + " obj.length:" + obj.length);
  19. }
  20. write("<<< Stop pop test for object: " + obj);
  21. }
  22. var testList = new Array(new Array() , new Object());
  23. for (var i=0;i<testList.length;i++) {
  24. TestPop(InitObject(testList[i]));
  25. }