I have a JavaScript class representing a car, which is constructed using two parameters, which represent the make and model of the car:
function Car(make, model) {
this.getMake = function( ) { return make; }
this.getModel = function( ) { return model; }
}
Is there a way to verify that the make and model supplied to the constructor are strings? For example, I want the user to be able to say,
myCar = new Car("Honda", "Civic");
But I don't want the user to be able to say,
myCar = new Car(4, 5.5);