I need to check whether a class definition provides either via inheritance or not, a specific method. Do I need to travel the prototype chain to accomplish this?
function TestClass(config){
//NOTE: cannot instantiate class because if config not valid Error is thrown
}
TestClass.prototype.sampleMethod = function(){};
function isDefined(klass){
console.log(typeof klass.sampleMethod); //'undefined'
console.log('sampleMethod' in klass); //false
console.log(klass['sampleMethod']); //undefined
console.log(typeof klass.prototype.sampleMethod); //'function' ...inheritance?
}
isDefined(TestClass);