Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does TypeError non_object_property_load mean?

I see this error a bunch in javascript that I'm debugging. In the JS console Chrome says something very similar to

TypeError
    arguments: Array[2]
    message: "-"
    stack: "-"
    type: "non_object_property_load"
    __proto__: Error

I can usually work my way to the underlying problem, but in general what does the error represent?

Is there any way to get a stack trace to the line that caused the problem?

like image 639
Leopd Avatar asked Oct 12 '11 20:10

Leopd


1 Answers

You're trying to access something from null or undefined.

For example, this code will throw such an error:

null.foo;

You should check which properties you're accessing from which objects, and use something like obj && obj.prop instead of just obj.prop.


You can get the stack trace using:

console.log(new Error().stack);

The - means the property is a getter, and is not displayed automatically because a getter can have side effects. The stack is available though (the - does not mean "not available"); you just have to access it explicitly.

like image 196
pimvdb Avatar answered Sep 21 '22 06:09

pimvdb