array_splice3.js 706 B

123456789101112131415161718
  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 echo = WScript.Echo;
  6. // no argument
  7. var a = [0, 1, 2, 3, 4];
  8. echo("splice no arg:", a, "||", a.splice());
  9. // "start" only
  10. var starts = [-2, 0, 2, 8];
  11. for (var i = 0; i < starts.length; i++) {
  12. var a = [0, 1, 2, 3, 4];
  13. var start = starts[i];
  14. echo("splice at " + start + ":", a, "||", a.splice(start));
  15. }