ArrayResize.js 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. //
  6. // Allocate an initial array and set some fields.
  7. //
  8. var a1 = new Array();
  9. a1[2] = "B";
  10. a1[3] = "C";
  11. //
  12. // Cause the array to grow in storage.
  13. //
  14. a1[20] = "T";
  15. //
  16. // Dump the contents of the array, ensuring that uninitialized fields are properly set to
  17. // 'undefined'.
  18. //
  19. for (var idx = 0; idx < a1.length; idx++)
  20. {
  21. var val = a1[idx];
  22. if (val == undefined)
  23. {
  24. WScript.Echo("undefined");
  25. }
  26. else if (val == null)
  27. {
  28. WScript.Echo("null");
  29. }
  30. else
  31. {
  32. WScript.Echo(val);
  33. }
  34. }