I would like to analyse the classes of three.js library. I have a function, that can find out, if the given class relaying 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)
}
And I also would like to have a function that returns 2 arrays. One with properties and one with methods. When iterating over "object", I can determine what kind of the member is, but how can i check that, it is not inherited? If parent is exist and I store a reference of it, negating the result of parentObject.hasOwnProperty does not work.
for (var member in object) {
if (typeof object[member] === "function") {
if (!parentObject.hasOwnProperty(member)) {
methods.push(member)
}
}
else {
//...
}
}