checking if a method already exists before adding a method to object in JavaScript
<p>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.</p>

<p>Note that isBlack method might come to Car from Car itself or through prototype.</p>

<pre><code>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';
}
</code></pre>
