call1.js 951 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. function safeCall(func)
  7. {
  8. try
  9. {
  10. return func();
  11. }
  12. catch (ex)
  13. {
  14. write(ex.name + " (" + ex.number + "): " + ex.message);
  15. }
  16. }
  17. var x = "global.x";
  18. var o = { x : "object.x" }
  19. function foo(a) {
  20. write("In foo: " + a + ". this.x: " + this.x);
  21. }
  22. foo(1);
  23. safeCall(function() { foo(1); eval('foo(1) = true;'); });
  24. //foo.call(this, 2);
  25. foo.call(o, 3);
  26. var a = new Array();
  27. for (var i=0; i<10; i++) {
  28. a[i] = i * i + 1;
  29. }
  30. write(Array.prototype.concat.call(a));