I'm looking for a way to get all the arguments of a javascript object. Only those specified in the constructor, not those inherited from the parent classes. I have found a lot of examples and tutorial online, including this website but none of them filtered only the argument specifically defined in a class. I couldn't find any way to extract it myself. If for instance, I have a class defined like this:
class Camera extends Node{
constructor(type="Camera", name="Camera", position=[0,0,0], target=[0,0,0], up=[0, 1, 0]) {
super(type, name);
...
I want to make sure I only get: "type", "name", "position", "target" and "up". I tried many variations at this point but one of the last ones was:
printClassArguments (object) {
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
const value = object[key];
console.log("found argument "+key)
}
}
}
Unfortunately that output:
scene.printClassArguments (scene.cameras[0])
found property _type
found property _name
found property _components
found property _id
found property cameraType
found property _target
found property _up
found property _fov
found property _near
found property _far
found property _aspect
found property _projectionMatrix
found property _viewMatrix
found property transform
found property _defaultViewMatrix
found property _defaultTarget
found property _sensitivity
Which is not what I want. What am I missing?
Thank you in advance!