I'm reading a book "How to Do Everything with JavaScript" and I'm currently learning how to define classes. The book says there are 2 ways. first using functions in javascript 1.x. second, using class in javascript 2.0.
what I'm trying is:
class Car {
var Make : String;
var Model : String;
var Year : Integer;
var Color : String;
var FullName : String;
function Car (make, model, year, color) {
this.Make = make;
this.Model = model;
this.Year = year;
this.Color = color;
this.FullName = this.Year + " " +
"<b>" + this.Make + "</b> " +
this.Model;
}
}
var mySUV = new Car("Toyota", "4Runner SR5",2001, "Thundercloud");
document.write ("I drive a " + mySUV.FullName);
The code is not working when I'm trying to run it. I use komodo editor to develop and when I define a class like I mentioned before, It gives me a warning "strict warning: class is a reserved identifier".
Is there something wrong with the code? Thanks in advance for any help.