Is there an equivalent to the Python _
in JavaScript referencing the last value printed in the console?
I'm especially interested in Chrome.
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.
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.
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.
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.
In Chrome and Firefox, you can use $_
. It references the return value from the last evaluation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With