10
Beginner JavaScript question. I'm sort of spoiled on the dir built-in function from Python. I want to discover the properties/methods of any object in the node.js REPL. I have already seen this question; the accepted answer fails (in the node REPL) in the simple case of an empty array []. For example:
for(var prop in []){console.log(prop);} # returns undefined, prints nothing
[].length # returns 0
Since the for loop does not discover the array's length method, I do not consider that to be proper introspection. So, could someone fill in the blank here:
function magic(some_object) {
# magic goes here
}
console.log(magic([])) # should print a list that includes 'length'
Or is this simply not possible, or only possible for "user types"?