function haha(){
console.log('haha');
}
console.log(haha());
打印:
haha
undefined
是不是因为如果你没有在函数中指定return,它将返回undefined,这就是第二个console.log输出的内容?
最佳答案
它返回undefined
,因为基本上你的函数不返回任何内容。
你可以例如返回一个“haha”字符串或任何你喜欢的内容。
function haha(){
console.log('haha');
return 'haha';
}
console.log(haha());
关于javascript - console.log 内具有控制台日志输出的函数打印 undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43258037/