newFunction.js 910 B

12345678910111213141516171819202122232425262728
  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 functionCode1 = new Function("arg", "return arg;");
  6. var functionCode2 = undefined;
  7. var captured = "ok";
  8. function setCode2()
  9. {
  10. var captured = "bob in setCode2";
  11. functionCode2 = new Function("arg", "return arg + ' ' + captured;");
  12. }
  13. setCode2();
  14. WScript.SetTimeout(testFunction, 50);
  15. function testFunction()
  16. {
  17. telemetryLog(`functionCode1: ${functionCode1("Hello")}`, true); //Hello
  18. telemetryLog(`functionCode2: ${functionCode2("Hello")}`, true); //Hello ok
  19. emitTTDLog(ttdLogURI);
  20. }