简体   繁体   English

javascript输出返回控制台

[英]javascript output return to console

When I do a return in the console, Why does it output to the screen? 当我在控制台中return时,为什么它会输出到屏幕? I'm using chrome, but it probably does this in Firefox also. 我正在使用chrome,但它可能也在Firefox中也是如此。 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"

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. 这是控制台的功能(或更确切地说,围绕它的UI-有时会有一个单独的输入字段),键入JavaScript表达式将评估该表达式并显示结果。 It can be very useful for debugging! 这对于调试非常有用!

More generally, it echoes the value of the entered expression, for example writing 5+5 in console and pressing enter would echo 10 . 更一般地,它回显输入表达式的值,例如,在控制台中写入5+5并按Enter将回显10

For reasoning, see http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop 有关推理的信息,请参见http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM