Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: last value printed in console

Is there an equivalent to the Python _ in JavaScript referencing the last value printed in the console?

I'm especially interested in Chrome.

like image 347
Randomblue Avatar asked Aug 22 '12 18:08

Randomblue


People also ask

How do I print a value from console?

The console. log() is a function in JavaScript that is used to print any kind of variables defined before in it or to just print any message that needs to be displayed to the user.

How do I return a value from console log?

console. log() is a function used to print information to the console. return on the other hand is a call to pass some value back up to where the call was made. For instance, let's say you create a function called square() that takes in a single numeric parameter and returns that value squared.

How can you print what is stored in a JavaScript variable?

JavaScript does not have any print object or print methods. You cannot access output devices from JavaScript. The only exception is that you can call the window.print() method in the browser to print the content of the current window.

How do you display data in the browser console using JavaScript?

In Chrome, we can select View > Developer > JavaScript Console menu to bring up the Console. Alternatively, we can also use the shortcut key: Cmd + Option + J on OS X, and Ctrl + Shift + J on Windows.


1 Answers

In Chrome and Firefox, you can use $_. It references the return value from the last evaluation.

enter image description here

like image 102
Paul Irish Avatar answered Oct 11 '22 08:10

Paul Irish