2
0

call2.js 868 B

123456789101112131415161718192021222324252627282930
  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. function write(v) { WScript.Echo(v + ""); }
  6. var x = "global.x";
  7. var o = { x : "object.x" }
  8. function foo(a) {
  9. var str = "In foo: " + a + ". this.x: " + this.x + " type: " + typeof(this);
  10. write(str);
  11. return str;
  12. }
  13. foo.call(this, 2);
  14. foo.call();
  15. foo.call(0);
  16. foo.call(void 0);
  17. foo.call()===foo.call(0);
  18. write(foo.call()===foo.call(void 0));
  19. foo.apply();
  20. foo.apply(0);
  21. foo.apply(void 0);
  22. foo.apply()===foo.apply(0);
  23. write(foo.apply()===foo.apply(void 0));