stringindex.js 890 B

12345678910111213141516171819202122232425262728293031323334353637
  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 write(args)
  6. {
  7. WScript.Echo(args);
  8. }
  9. write("Scenario 1");
  10. var sl = "hello";
  11. for (var i=0;i<8;i++)
  12. {
  13. write(sl.propertyIsEnumerable(i));
  14. write(sl.hasOwnProperty(i));
  15. write(sl[i]);
  16. }
  17. write("Scenario 2");
  18. var so = new String("hello");
  19. so[1] = 10;
  20. so[4] = 20;
  21. so[7] = 30;
  22. so.x = 20;
  23. for (var i=0;i<8;i++)
  24. {
  25. write(so.propertyIsEnumerable(1));
  26. write(so.hasOwnProperty(i));
  27. write(so[i]);
  28. }
  29. write(so.propertyIsEnumerable("x"));
  30. write(so.hasOwnProperty("x"));
  31. write(so["x"]);