function SuperClass(){
this.superClassMethod = function(){
log('This was invoked from the superClass Method');
}
}
function SubClass(){
this.subClassMethod = function(){
log('This was invoked from the subClass Method');
}
}
// SubClass Inherits the SuperClass
SubClass.prototype = new SuperClass;
// correct the constructor pointer
SubClass.prototype.constructor = SubClass;
var instanceA = new SubClass();
// Method from SubClass
instanceA.subClassMethod();
// Method inherited from the SuperClass
instanceA.superClassMethod();
// "true": instanceA inherited the SuperClass
log(instanceA instanceof SuperClass);
// "true": instanceA is an instance of SubClass
log(instanceA instanceof SubClass);
// log Results function
function log(arg){
var timeStamp = new Date();
var printStr = timeStamp+'<br />'+arg;
var str = '<div class="log-item"><pre>'+timeStamp+'</pre><p>'+arg+'</p></div>'
var logger= document.getElementById('logger');
logger.innerHTML+= str;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!