SwVitaliy

Untitled

Apr 30th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. function T() { this.a='a' }
  2. >undefined
  3. T.prototype = { o: { p:1 } }
  4. >Object
  5. t1 = new T
  6. >T
  7. t2 = new T
  8. >T
  9. t1.o.p = 2
  10. >2
  11. t2.o.p
  12. >2 ---------------- FAIL
  13. T.prototype = { init: function() { this.o = { p:1 } } }
  14. >Object
  15. function T() { this.a='a'; this.init() }
  16. >undefined
  17. T.prototype = { init: function() { this.o = { p:1 } } }
  18. >Object
  19. t1 = new T
  20. >T
  21. t2 = new T
  22. >T
  23. t1.o.p = 2
  24. >2
  25. t2.o.p
  26. >1 ---------------- SUCCESS
Advertisement
Add Comment
Please, Sign In to add comment