symbol.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 x = 'Hello';
  6. var xs = Symbol("Hello");
  7. var ys = xs;
  8. var zs = Symbol("Hello");
  9. var obj = {};
  10. obj[x] = 1;
  11. obj[xs] = 2;
  12. obj[zs] = 3;
  13. var symObj = Object(zs);
  14. WScript.SetTimeout(testFunction, 50);
  15. /////////////////
  16. function testFunction()
  17. {
  18. telemetryLog(`typeof zs: ${typeof(zs)}`, true); //symbol
  19. telemetryLog(`typeof symObj: ${typeof(symObj)}`, true); //object
  20. telemetryLog(`xs == ys: ${xs == ys}`, true); //true
  21. telemetryLog(`xs == zs: ${xs == zs}`, true); //false
  22. telemetryLog(`obj[x]: ${obj[x]}`, true); //1
  23. telemetryLog(`obj.Hello: ${obj.Hello}`, true); //1
  24. telemetryLog(`obj[xs]: ${obj[xs]}`, true); //2
  25. telemetryLog(`obj[ys]: ${obj[ys]}`, true); //2
  26. telemetryLog(`obj[zs]: ${obj[zs]}`, true); //3
  27. telemetryLog(`obj[symObj]: ${obj[symObj]}`, true); //3
  28. emitTTDLog(ttdLogURI);
  29. }