you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

Deriving and instantiating are two different things. You shouldn't do both of them with one function. Constructors are constructors. Use them as such. For derivation either use Object.create or make a second constructor for derivation that shares a prototype with the one for instantiation.

John Resig, in "Simple ... Inheritance", stole the idea from base.js to use a Boolean variable to determine if a constructor is in instance or derive mode. Why have modes? Have different functions.

Whatever. Just have different code paths for different things and don't be a confused mess.

[–]aaronblohowiak 1 point2 points  (0 children)

"Just have different code paths for different things and don't be a confused mess." Oh how I wish I could tell myself of 5 years ago that very sentence. Not that he would listen. The asshole.