Array.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. var a = new Array(10);
  6. var b = new Array();
  7. var c = new Array("muck", 3.2, 0, 18);
  8. c[-1] = "minus 1";
  9. WScript.Echo("Store a single item in a");
  10. a[1] = 10;
  11. WScript.Echo(a[1]);
  12. WScript.Echo("Store a single item in b");
  13. b[3] = 99;
  14. WScript.Echo(b[3]);
  15. for (var i = -1; i < c.length; i++) {
  16. WScript.Echo(c[i]);
  17. }
  18. // Test boolean expressions in an initializer
  19. var x = {}, y = false;
  20. WScript.Echo([x||y]);
  21. WScript.Echo([x&&y]);
  22. WScript.Echo([x ? y : x]);
  23. WScript.Echo([y ? x : y]);
  24. WScript.Echo([y||x]);
  25. WScript.Echo(y&&x);
  26. WScript.Echo([x||y, x&&y, x ? y : x, y ? x : y, y||x, y&&x]);
  27. // Test some boundary property names
  28. var o = [];
  29. o["4294967294"] = 100;
  30. WScript.Echo(o["4294967294"]);
  31. o["4294967295"] = 101;
  32. WScript.Echo(o["4294967295"]);
  33. o["4294967296"] = 102;
  34. WScript.Echo(o["4294967296"]);
  35. o["4088701331"] = 103;
  36. WScript.Echo(o["4088701331"]);
  37. o["40887013312"] = 104;
  38. WScript.Echo(o["40887013312"]);
  39. o["4088.7013"] = 105;
  40. WScript.Echo(o["4088.7013"]);
  41. o["408870133X"] = 106;
  42. WScript.Echo(o["408870133X"]);