constructor.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. function foo(x) {
  7. this.x = x;
  8. }
  9. var f = new foo(10);
  10. foo.prototype = { y : 10 };
  11. var f1 = new foo(20);
  12. write("f : " + f.y); // should print undefined
  13. write("f1: " + f1.y); // should print 10
  14. function bar(x, y) {
  15. this.x1 = x;
  16. this.x2 = x;
  17. this.x3 = x;
  18. this.x4 = x;
  19. this.x5 = x;
  20. this.x6 = x;
  21. this.x7 = x;
  22. this.x8 = x;
  23. this.x9 = x;
  24. this.y1 = y;
  25. this.y2 = y;
  26. this.y3 = y;
  27. this.y4 = y;
  28. this.y5 = y;
  29. this.y6 = y;
  30. this.y7 = y;
  31. this.y8 = y;
  32. this.y9 = y;
  33. }
  34. var b1 = new bar(10, 20);
  35. var b2 = new bar(30, 40);
  36. write(b2.y8);