'Get the file name where a JavaScript Object has been defined using JS only (no dev tool)
Let's imagine we visit a random website where N javascript files are loaded:
- file1.js
- file2.js
- file3.js
...
- fileN.js
We have the following global variable of type Object window.myObject
The question is: is there a way to get the file name where window.myObject
has been defined?
I know this can be done using the browser's dev tools, but I would like to have a function that does this for me.
Where I'm at: I feel like there might be a way to add a setter to window.myObject
, to add a test property, and to console.trace()
via the setter, but I'm not advanced enough to understand how exactly (and to even know if this is doable).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|