var.js 932 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 defvar = 10;
  6. WScript.Echo(defvar);
  7. try
  8. {
  9. WScript.Echo(undefvar);
  10. }
  11. catch (e)
  12. {
  13. WScript.Echo(e.message);
  14. }
  15. WScript.Echo(this.defvar);
  16. WScript.Echo(this.undefvar);
  17. function func()
  18. {
  19. WScript.Echo(defvar);
  20. try
  21. {
  22. WScript.Echo(undefvar);
  23. }
  24. catch (e)
  25. {
  26. WScript.Echo(e.message);
  27. }
  28. // this refers to the global object
  29. WScript.Echo(this.defvar);
  30. WScript.Echo(this.undefvar);
  31. return this;
  32. }
  33. var g = func();
  34. WScript.Echo(g.defvar);
  35. WScript.Echo(g.undefvar);