Can someone post me a proper example of an empty class in Javascript with an initialize or constructor (if supported)? I found several ways to make classes and they are all a bit weird.
Is the code below the proper way?
Is the code below the proper way?
Code:
function MyClass() { this.initialize.apply(this, arguments); }//MyClass.prototype = Object.create(Sprite_Base.prototype); // What is this... subclassing?MyClass.prototype.constructor = MyClass;MyClass.prototype.initialize = function(args){ // This function should be automatically called upon object creation // do stuff here console.log(args);};
Code:
var test = new MyClass('some argument')