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

javascript - Chrome Developer Tools - How to find the source where variables shown in the console are defined - Stack Overflow

programmeradmin5浏览0评论

In the console of Chrome Developer Tools we are able to view all the variables and functions that are in scope for a given page, like shown in this screenshot which shows a function called "buildIssInitObject" defined on our favorite shopping site .

But what is not shown is where this function or variable is defined. Usually a page loads many source files, so how to see in which of these a given function or variable displayed in the console has been defined?

In the console of Chrome Developer Tools we are able to view all the variables and functions that are in scope for a given page, like shown in this screenshot which shows a function called "buildIssInitObject" defined on our favorite shopping site http://grab.by/RbjQ.

But what is not shown is where this function or variable is defined. Usually a page loads many source files, so how to see in which of these a given function or variable displayed in the console has been defined?

Share Improve this question edited Jun 30, 2016 at 15:44 AbuMariam asked Jun 30, 2016 at 15:39 AbuMariamAbuMariam 3,67813 gold badges56 silver badges85 bronze badges 2
  • on the right corner you may see the file name and line umber – brk Commented Jun 30, 2016 at 15:40
  • no, I don't see that – AbuMariam Commented Jun 30, 2016 at 15:43
Add a ment  | 

2 Answers 2

Reset to default 14

You can find all references, including the declaration, by searching in the Sources tab using the shortcut Ctrl+Shift+F (Window) or Cmd+Opt+F (Mac). Click on the result to open the file.

Note: The file that the function definition exists in is not necessarily the original file created during development. In this case, the code is bundled from many different sources.

Alternatively, use the overflow menu to open the Search bar if the shortcut has been hijacked by another application, such as Spectacle:

For functions, Chrome also lets you jump directly to the function definition.

You can either do this by hovering over the variable and clicking the link.

Or you can right-click on the variable and select "Show Function Definition".

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论