Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get inline function definitions back in Chrome's JavaScript console

Chrome's JavaScript console used to have a very helpful feature where if you entered the name of any function visible in the current scope it would print the complete definition of that function. Essentially as described in this answer here.

Some time ago (I think at least a couple of months, could be more) it stopped doing this, however, and entering a function name now gives a very unhelpful response, like:

enter image description here

I know I can click on that line (or right-click, and choose 'Show Function Definition') to be shown the function-definition in the 'Sources' tab, but that's very clunky compared to the previous inline function definitions (for a workflow that's typically along the lines of 'get the function definition, copy/paste into the console, change a few things, then overwrite the original function definition').

Another trick is to add a + "" after the function name (as in jobClicked + "" instead of jobClicked), which shows the code in the console but loses all of the syntax highlighting.

Is there any way to get the JavaScript console to go back to its previous behavior of displaying the complete function definition inline inside of the JavaScript console, with the syntax-highlighting intact?

like image 527
aroth Avatar asked Jul 29 '15 07:07

aroth


People also ask

Where is JavaScript function in Chrome?

To find the JavaScript function definition in Google Chrome, open the web browser and press F12 to reach Developer Tools. Search for function and that's it.

How do I use JavaScript console in Chrome?

Open Chrome, press Ctrl+Shift+j and it opens the JavaScript console where you can write and test your code.

How do you define a function in console?

When inspecting an object that contains in the Console, right click on a function and you will see a handy "Show function definition". It will take you to the place in the source code where the function is defined! Alternatively, you can just hover over the function () { word to preview function body in a tooltip.

How do I run a script in browser console?

Right-click in a webpage and then select Inspect. DevTools opens. Or, press Ctrl + Shift + J (Windows, Linux) or Command + Option + J (macOS), to directly open the DevTools console. If necessary, click in DevTools to give it focus, and then press Esc to open the Console.


1 Answers

It's working in version 54. You can update your Chrome browser.

Example function table:

Example function table

Chrome version:

Chrome version

like image 100
Jithendranath Gupta Avatar answered Sep 27 '22 21:09

Jithendranath Gupta