最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught ReferenceError in Chrome dev tools - Stack Overflow

programmeradmin2浏览0评论

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

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

Share Improve this question asked Sep 8, 2015 at 13:20 CooperCooper 1971 silver badge12 bronze badges 5
  • 1 are you minifying the JS code and using a source map? – sahbeewah Commented Sep 8, 2015 at 13:23
  • are you actually on the activate() line, or have you stepped into the activate function? – sahbeewah Commented Sep 8, 2015 at 13:27
  • I'm minifying the JS code and using a source map. Enable JavaScript source maps is checked in the settngs. – Cooper Commented Sep 8, 2015 at 13:28
  • Minifiers usually changes variable & function names. – user3946265 Commented Sep 8, 2015 at 13:29
  • I have not stepped into the activate function. – Cooper Commented Sep 8, 2015 at 13:29
Add a ment  | 

1 Answer 1

Reset to default 7

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
发布评论

评论列表(0)

  1. 暂无评论