simple_stackfunc.js 700 B

123456789101112131415161718192021222324
  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 test()
  6. {
  7. var i = 0;
  8. var simple_stackfunc = function() // this can be stack allocated
  9. {
  10. if (i == 0)
  11. {
  12. i++;
  13. return simple_stackfunc();
  14. }
  15. return i;
  16. }
  17. return simple_stackfunc();
  18. }
  19. WScript.Echo(test());
  20. WScript.Echo(test());