I would like to add isBlack method to Car only if this method is not already present. At the bottom of the page I have done that by checking for both in prototype and in the Car object itself. I was wondering if there is a better way to handle the case. I don't like the double check.
Note that isBlack method might come to Car from Car itself or through prototype.
function Vehicle(name){
this.name = name;
};
Vehicle.prototype.tyres = 4;
function Car(){}
Car.prototype = new Vehicle();
Car.prototype.constructor = Car;
if !(Car.isBlack || Car.prototype.isBlack){
Car.prototype.isBlack = 'false';
}