Closed GoogleCodeExporter closed 9 years ago
right, this is working as intended. All objects on the prototype are shared. I
believe Closure Linter will warn you about this if you do it.
Original comment by Nicholas.J.Santos
on 27 Nov 2011 at 9:44
It sounds like you expect goog.inherits to copy members from one class to
another (also known as mixins or composition-based inheritance). That is not
the case. Closure uses true prototypal inheritance. Anything on a superclass
prototype is shared with all subclasses as well. Closure style has a rule that
only primitive values should be placed on the prototype chain. Most often, the
intention is to use an empty object/array as a default, but what ends up
happening is exactly what you described: methods end up mutating the prototype
object instead of an instance-specific one.
Original comment by JayYoung...@gmail.com
on 27 Nov 2011 at 9:50
Thanks guys, I thought so too.
Best wishes,
- Bernd
Original comment by bernd.pa...@gmail.com
on 28 Nov 2011 at 6:44
Original issue reported on code.google.com by
bernd.pa...@gmail.com
on 27 Nov 2011 at 9:02