console.log和javascript中的返回之间的区别? [英] Difference between console.log and return in javascript?

查看:391
本文介绍了console.log和javascript中的返回之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在javascript中使用 console.log 返回的情况是什么?

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>


使用返回时语句,函数将停止执行,并返回指定的值。

When using the return statement, the function will stop executing, and return the specified value.

这篇关于console.log和javascript中的返回之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆