I am trying to use OOP based javascript/jQuery. I want to put all my JS function inside a class, so it can be easily overridden/hooked.
I tried with a simple OOP code, but its giving type error: not a constructor. Please have a look at my code and guide me what is wrong in my code, and how to fix it.
var myTestClass = {
testAttribute : 'test', // atttribute
testMethod : function(){ alert( testAttribute); }
};
var my = new myTestClass();
my.testMethod();
Thanks
or
or if you use jQuery
or with inheritance and abstract classes
Or, with es6
//file test.js
//file test2.js
//file main.js
to view your alert:
another approach:
Lazy Inheritance example: