Difference between console.log and return in javascript?(javascript中的console.log和return之间的区别?)
问题描述
在 javascript 中使用 console.log
和 return
的实例有哪些?
What are the instances when you would use console.log
and return
in javascript?
我刚开始学习 javascript,我想知道在哪些情况下我会使用它们?
I've just started learning javascript and I want to know what are some instances when I'd use them?
推荐答案
来自 http://blogs.msdn.com/b/cdndevs/archive/2011/05/26/console-log-say-goodbye-to-javascript-alerts-for-debugging.aspx
console.log 将显示传递给 log 方法的参数控制台窗口.使用此方法在控制台窗口.
console.log will display the parameter passed to the log method in the console window. Use this method to display a string or variable in the console window.
您也可以在代码中使用控制台类,就像我们一样使用 JavaScript 警报.
You can use the console class in your code as well, much like we can use JavaScript alerts.
<script type = "text/javascript">
function tryConsole() {
console.log("hello world");
}
</script>
当使用return
语句时,函数将停止执行,并返回指定的值.
When using the return
statement, the function will stop executing, and return the specified value.
这篇关于javascript中的console.log和return之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:javascript中的console.log和return之间的区别?


基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01