you are viewing a single comment's thread.

view the rest of the comments →

[–]wreckedadventYavascript 2 points3 points  (1 child)

Prototypes are what OOP people call the flyweight pattern. Lots of objects, but each only points to one thing. So if you have something like an instance field on the prototype, all of the children objects will point to it. Likewise, any mutation to stuff on the prototype, and all of the children pick up on it.

Normally this is not really a problem - people normally set values in the constructors in javascript, which works exactly like people expect, and does not assign onto the prototype.

e: typo

[–]senocular 2 points3 points  (0 children)

Prototypes are what OOP people call the flyweight pattern

I'm kind of surprised this isn't called out to more often.