constructor1.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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(v) { WScript.Echo(v + ""); }
  6. var o;
  7. o = Object();
  8. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  9. o = new Object();
  10. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  11. o = Object(null);
  12. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  13. o2 = new Object(null);
  14. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  15. o = Object(undefined);
  16. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  17. o = new Object(undefined);
  18. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  19. o = Object(true);
  20. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  21. o = new Object(true);
  22. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  23. o = Object(new Boolean(false));
  24. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  25. o = new Object(new Boolean(false));
  26. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  27. o = Object(0);
  28. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  29. o = new Object(0);
  30. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  31. o = Object(new Number(10));
  32. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  33. o = new Object(new Number(10));
  34. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  35. o = Object("hello");
  36. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  37. o = new Object("hello");
  38. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  39. o = Object(new String("hello"));
  40. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  41. o = new Object(new String("hello"));
  42. write("o:" + o + " typeof(o):" + typeof(o) + " o.toString():" + Object.prototype.toString.call(o));
  43. var b = new Boolean(true);
  44. b.x = 10;
  45. o = new Object(b);
  46. write("o.x = " + o.x);
  47. var n = new Number(100);
  48. n.x = 20;
  49. o = new Object(n);
  50. write("o.x = " + o.x);
  51. var s = new String("world");
  52. s.x = 30;
  53. o = new Object(s);
  54. write("o.x = " + o.x);