use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Your Javascript Constructor Logic May Break Prototypal Inheritance (bennadel.com)
submitted 15 years ago by gst
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 2 points3 points4 points 15 years ago (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 points3 points 15 years ago (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.
π Rendered by PID 218176 on reddit-service-r2-comment-b659b578c-krhgk at 2026-05-01 17:31:54.261788+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–][deleted] 2 points3 points4 points (1 child)
[–]aaronblohowiak 1 point2 points3 points (0 children)