I am interested in analyzing the classes within the three.js library. I have developed a function that can determine whether a given class relies on another class or not.
function getParent (className) {
var parent = null;
var object = new THREE[className]();
for (var a in THREE) {
if (typeof THREE[a] === "function" && object instanceof THREE[a] && a !== className) {
parent = a;
break;
}
}
return parent;
}
Additionally, I would like to create a function that returns two arrays - one containing properties and the other containing methods. While iterating over an "object", I want to be able to differentiate between inherited and non-inherited members. However, when there is a parent present and I store a reference to it, simply negating the result of parentObject.hasOwnProperty does not yield the desired outcome.
for (var member in object) {
if (typeof object[member] === "function") {
if (!parentObject.hasOwnProperty(member)) {
methods.push(member);
}
}
else {
//...
}
}