arguments.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 = foo(1, 2, 3);
  6. var y = fooDeleted(1, 2, 3);
  7. function foo(a, b, c)
  8. {
  9. var res = {};
  10. var args = arguments;
  11. res.length = function() { return args.length; };
  12. res.named = function() { return b; };
  13. res.position = function() { return args[1]; };
  14. return res;
  15. }
  16. function fooDeleted(a, b, c)
  17. {
  18. delete arguments[1];
  19. var res = {};
  20. var args = arguments;
  21. res.length = function() { return args.length; };
  22. res.named = function() { return b; };
  23. res.position = function() { return args[1]; };
  24. return res;
  25. }
  26. WScript.SetTimeout(testFunction, 20);
  27. function testFunction()
  28. {
  29. telemetryLog(`xlength: ${x.length()}`, true); //3
  30. telemetryLog(`xnamed: ${x.named()}`, true); //2
  31. telemetryLog(`xposition: ${x.position()}`, true); //2
  32. telemetryLog(`ylength: ${y.length()}`, true); //3
  33. telemetryLog(`ynamed: ${y.named()}`, true); //2
  34. telemetryLog(`yposition: ${y.position()}`, true); //undefined
  35. emitTTDLog(ttdLogURI);
  36. }