0

When I do a return in the console, Why does it output to the screen? I'm using chrome, but it probably does this in Firefox also. Is it assuming the console is the caller and there's a built-in function that echos the returned value?

function mike() {return "fsadf";}
mike()
"fsadf"
1
  • it doesn't output to the screen for me.. Commented Jul 23, 2013 at 14:52

2 Answers 2

0

More generally, it echoes the value of the entered expression, for example writing 5+5 in console and pressing enter would echo 10.

For reasoning, see http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop

Sign up to request clarification or add additional context in comments.

Comments

0

It's a feature of the console (or rather, the UI that surrounds it - sometimes there's a separate input field) that typing in a JavaScript expression will evaluate that expression and display the result. It can be very useful for debugging!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.