JSFiddle - React, Tailwind, and code Playground

JavaScript

//In functions.js
function extend(base, sub, methods) {
    sub.prototype = Object.create(sub.prototype);
    sub.prototype.constructor = sub;
    sub.base = base.prototype;

    for(var name in methods) { sub.prototype[name] = methods[name]; }

    return sub;
}

//In classes.js
function Stimulus(module_id, unit_id, attributes) {
    this.attributes = attributes;
    this.module_id = module_id;
    this.unit_id = unit_id;
    //create some other class variables based on this.attributes, this.module_id, and this.unit_id
}

Stimulus.prototype._getStimulus = function() { //retrieve from database 
}
//other functions here

//In classes.js
ImageStimulus = (function() {
    var $this = function(module_id, unit_id, attributes) {
        $this.base.constructor.call(this, module_id, unit_id, attributes);
    };

    extend(Stimulus, $this, {
        initialize: function() {
            this.fixation_cross = this.attributes['Fixation Cross'] ? this.attributes['Fixation Cross'] : false;
            //do other stuff
        }
        //other functions here
    });

    return $this;
})();


var foo = function (module_id) {
	var stimulus_objects = [];

	var someLimit = 10;

	for(var i = 0; i < someLimit; i++) {
		//module_id is passed directly to this function
		var unit_id = "some source";//some source;
		var stimulus_attributes = "some source"; //some source;

		stimulus_objects[i] = new ImageStimulus(module_id, unit_id, stimulus_attributes);
		stimulus_objects[i].initialize();
	}
}

foo(1);