Merbin Joe
Merbin Joe

Reputation: 121

How can I find the js file name of the function definition from given function name?

I have many external javascript files, now I have very difficult to find which .js file contain function definition of the given function name from inspect element console window.

I have tried the below
In the console window I have enter just the function name, the function definition is shown, but I can not find the function definition source .js file.

enter image description here

Upvotes: 2

Views: 2779

Answers (3)

Grim
Grim

Reputation: 2030

use inspect(setcode).

From Devtools docu:

When passing a function to inspect, the function opens the document up in the Sources panel for you to inspect

Upvotes: 11

Murtadha S.
Murtadha S.

Reputation: 471

You can either use "grep" or find a good editor (VS Code or Atom).

  1. About grep you can write

    grep -Ril "[text to search for]" [path to search in]

    in the linux command line [terminal].

  2. And in Atom or VS Code you can search for it inside folder using ctrl+shift+f.

Upvotes: 1

Pramodh Valavala
Pramodh Valavala

Reputation: 752

The JS code gets loaded into the same namespace when they defined globally. Once loaded there is no way to tell from where the object has originated.

This is why you shouldn't pollute the global namespace. You should define objects/classes per file, at least while development/debugging.

Here is a good place to start to learn about OOP in JS

Upvotes: 0

Related Questions