array_slice.js 921 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. var x = [1, 2, 3, 4, 5, 6, 7, 8]
  6. WScript.Echo(x.slice(9,11));
  7. WScript.Echo(x.slice(1, "abc", 5, 9));
  8. WScript.Echo(x.slice());
  9. WScript.Echo(x.slice(3));
  10. WScript.Echo(x.slice(9));
  11. WScript.Echo(x.slice(-19));
  12. WScript.Echo(x.slice(-7, 4));
  13. WScript.Echo(x.slice(2, -4));
  14. WScript.Echo(x.slice(5, 2));
  15. WScript.Echo(x.slice(-12, -9));
  16. WScript.Echo(x.slice(-12, -15));
  17. var large = new Array(1000000);
  18. for (var i = 0; i < large.length; i++)
  19. {
  20. large[i] = 0;
  21. }
  22. s = large.slice(0, large.length - 1);
  23. WScript.Echo(s.length);