How and What prototype maked difference in javaScript classes?
Hi,
I have written class "IC" in a javaScript file whose code is like this:
- IC = function () {
this.var1 = null;
- this.var2 = null;
- this.name = 'acxs-334';
- this.turn = 'forward';
- }
- IC.prototype.getMonthsName = function (m) {
- return IC.MonthsName[m];
- }
-
- IC.MonthsName = ["Jan", "Feb", "Mar", "Apr"];
Next I have written this code but I am getting this error while accessing MonthsName : 'MonthsName.0' is null or not an object
function Person(gender) {
debugger;
var obj = new IC();
var month = obj.getMonthsName(2);
var month1 = obj.MonthsName[0]; //error coming
}
$(document).ready(function () {
var p = new Person();
});
Can anyone tell where is the mistake?