instanceOfCacheCrossRegistration.js 978 B

123456789101112131415161718192021222324252627282930313233343536
  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 obj = [];
  7. var proto_1 = [];
  8. var proto_2 = [];
  9. var count = 2;
  10. function Ctor1()
  11. {
  12. this.x = 0;
  13. this.y = 1;
  14. }
  15. function Ctor2() {
  16. this.a = 0;
  17. this.b = 1;
  18. }
  19. function test(o1, o2, ctor1, ctor2)
  20. {
  21. var isO1Ctor1 = o1 instanceof ctor1;
  22. var isO2Ctor1 = o2 instanceof ctor1;
  23. write("o1 instanceof ctor1: " + isO1Ctor1);
  24. write("o2 instanceof ctor1: " + isO2Ctor1);
  25. }
  26. var o1 = new Ctor1();
  27. var o2 = new Ctor2();
  28. test(o1, o2, Ctor1, Ctor2);
  29. Ctor1.prototype = { x: 10, y: 20 };
  30. test(o1, o2, Ctor1, Ctor2);