JSFiddle - React, Tailwind, and code Playground

by Deepak Anand

JavaScript

// Dojo-declare's this.inherited() call breaks strict mode
//
// If you only want single-level inheritance, you dont need dojo/declare
// You can look up the super-class’s prototype chain to get at the super-method like so
//
// <SuperClass>.prototype.<superMethod>.apply(this, arguments)
// <SuperClass> is the module name
// <superMethod> is the method name
//
//Pros and cons
// Pro
// - Forward-looking pattern because it would be easy to switch to using ES6 classes which only support single-level inheritance
//Cons
//- Boilerplate

require([
  "dojo/_base/declare"  
], function(declare){
	'use strict';
  var SuperClass = declare(null, {
    superMethod: function(a, b, c){
      console.log(a+b+c);

    }  

  });


  var SubClass = declare(SuperClass, {
    superMethod: function(a, b, c){
      // sub class	
      SuperClass.prototype.superMethod.apply(this, arguments); 
    }  

  });

	var subclassInstance = new SubClass();
	subclassInstance.superMethod(1, 2, 3);


});