2
0

toString.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 a = 1;
  6. function foo() { var x = 1; }
  7. var m = foo.toString();
  8. WScript.Echo("Test 'toString()' on simple function:")
  9. WScript.Echo(m);
  10. WScript.Echo("Test 'toString()' on builtin function parseFloat:")
  11. WScript.Echo(parseFloat.toString());
  12. var an = function() {
  13. //anonymous
  14. a = a + 1;
  15. }
  16. WScript.Echo("Test 'toString()' on anonymous function:")
  17. WScript.Echo(an.toString());
  18. WScript.Echo("Test 'toString()' on an anonymous, unhinted function expression:");
  19. WScript.Echo(function () { });
  20. WScript.Echo("Test 'toString()' on an anonymous, unhinted function expression in parentheses (different behavior in standards mode):");
  21. WScript.Echo((function () { }));
  22. WScript.Echo("Test 'toString()' on parent and nested function:")
  23. function parent() {
  24. WScript.Echo("in parent");
  25. var bb = 1;
  26. function nested() {
  27. WScript.Echo("in nested");
  28. bb = 2;
  29. }
  30. nested();
  31. WScript.Echo(nested.toString());
  32. }
  33. parent();
  34. WScript.Echo(parent.toString());
  35. WScript.Echo('Test "somestring".indexOf.toString():')
  36. WScript.Echo("somestring".indexOf.toString());
  37. WScript.Echo('Test "somestring".indexOf:')
  38. WScript.Echo("somestring".indexOf);