6
votes

When I'm debugging my javascript I can't inspect my objects in the console. They always throw the error "Uncaught ReferenceError: X is not defined(...)

You can see in the screenshot below that I've paused the debugger at activate()

The console.log() calls both properly display what's in the respective object but when I try to see the objects by typing them in the console I get the errors.

I'm using Chrome 45.0.2454.85 m

enter image description here

1
are you minifying the JS code and using a source map? - sahbeewah
are you actually on the activate() line, or have you stepped into the activate function? - sahbeewah
I'm minifying the JS code and using a source map. Enable JavaScript source maps is checked in the settngs. - Cooper
Minifiers usually changes variable & function names. - user3946265
I have not stepped into the activate function. - Cooper

1 Answers

6
votes

If your code is minified, the variable and function names probably have changed.

If not:

test is only defined in the scope of userController, that's why you can not access it like this from the console.

vm is defined in the scope of userController aswell.

example:

var test = "1";
function foo(){
    var bar = "2";
    console.log(bar); #2
}

foo(); #will log "2"
console.log(test); #1
console.log(bar); #undefined