forin_lib.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 global = this;
  6. function Dump(s)
  7. {
  8. var o = global[s];
  9. if (!o) { return; }
  10. WScript.Echo("for..in " + s);
  11. for (var i in o)
  12. {
  13. WScript.Echo(" " + i + " = " + o[i]);
  14. }
  15. WScript.Echo("for..in " + s + " (with blah)");
  16. o.blah = "b";
  17. for (var i in o)
  18. {
  19. WScript.Echo(" " + i + " = " + o[i]);
  20. }
  21. try
  22. {
  23. var newobj = new o();
  24. WScript.Echo("for..in new " + s);
  25. for (var i in newobj)
  26. {
  27. WScript.Echo(" " + i + " = " + newobj[i]);
  28. }
  29. WScript.Echo("for..in " + s + " (with prototype.blah2)");
  30. o.prototype.blah2 = s;
  31. for (var i in newobj)
  32. {
  33. WScript.Echo(" " + i + " = " + newobj[i]);
  34. }
  35. }
  36. catch (e)
  37. {
  38. }
  39. WScript.Echo();
  40. }
  41. Dump("Object");
  42. Dump("Array");
  43. Dump("String");
  44. Dump("Function");
  45. Dump("Math");
  46. Dump("JSON");
  47. Dump("Number");
  48. Dump("Boolean");
  49. Dump("Date");
  50. Dump("RegExp");