Reputation: 150
Is there a way to get the source code of a function by using it's name in javacsript? I'm using the console and while like to see the source code of the function but can't find it. I can execute it in the console and typing only in the name returns the function object.
Upvotes: 0
Views: 335
Reputation: 370779
If you log it with console.dir
, at least in Chrome, you'll see an internal [[FunctionLocation]]
property that's clickable. For example, Stack Exchange uses jQuery, so doing console.dir($)
in the console shows:
Upvotes: 3
Reputation: 6259
you could achieve that by printing the function name only without invoke it
function sum(x, y){
return x + y;
}
console.log(sum)
Upvotes: 2