How do you create JavaScript in "Classes"?!
I am using:
function squarefu () {var classLevelVariable = 0; This.classFunction = function () {Warning ("classfunction has been called."); ClassFunction2 (); //Accident. Classfunction 2 is "undefined". } This.classFunction2 = function () {alert ("classfunction2 called"); }} I was never able to work with constructors. Tryed
this.New = function (arguments) which works once but not in the second category. Therefore, I have now completely abandoned them, using my own "initiation" functions, which act as constructor.
It is working once, but not twice, I have a typographical error between two classes ... but I think in the 19-year coding, maybe it is not.
I am using Chrome's debugger, and I have not found any errors despite having another function.
Javascript does not use class-based inheritance . Therefore, you can not create classes in Javascript, except that they should be used by making IMHO random and complex.
Javascript is a prototype language using the new keyword creates a new object based on prototype property of the constructor object.
You can get an idea on which basis you can use prototype inheritance to instantiate a new object here a prototype object:
Comments
Post a Comment