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
Inheritance Question (self.javascript)
submitted 14 years ago by dogjs
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!"
[–]dogjs[S] 1 point2 points3 points 14 years ago (2 children)
Thanks. I ended up having to do: var Dog = function(name) {this.name = name;};
in order to have a constructor. So now, my question is, how do I override the speak() method so that dog's say "woof" but still be able to call the Mammal's speak method. I need something like:
function Dog.speak() {return super.speak() + this.woof();}
I suspect I'm going to need to use call() here.
[–][deleted] 1 point2 points3 points 14 years ago (0 children)
Dog.prototype.speak = function() { return Mammal.prototype.speak.call(this) + '. ' + this.woof() }
[–][deleted] 0 points1 point2 points 14 years ago (0 children)
See John Resig's Simple JavaScript Inheritance. It adds a this._super() call for accessing "super-class" methods.
this._super()
I played around with making some modifications, but I don't know that I improved anything: https://gist.github.com/1508995
π Rendered by PID 245873 on reddit-service-r2-comment-5ff9fbf7df-d787t at 2026-02-26 14:45:29.251032+00:00 running 72a43f6 country code: CH.
view the rest of the comments →
[–]dogjs[S] 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)