我正在尝试在 JavaScript 中模拟多重继承,因此我需要找到一种方法来获取两个 JavaScript 对象的冲突方法名称列表。是否可以为两个对象生成一个函数名列表,然后找到两个类之间所有相同的函数名?
function base1(){
this.printStuff = function(){
return "Implemented by base1";
};
}
function base2(){
this.printStuff = function(){
return "Implemented by base2";
};
}
function getConflictingFunctionNames(object1, object2){
//get a list of conflicting function names between the two objects.
//to be implemented.
}
console.log(getConflictingFunctionNames(base1, base2)); //this should print ["printStuff"]