function haha(){
console.log('haha');
}
console.log(haha());
Prints:
haha
undefined
是因为如果你没有在函数中指定 return ,它将返回 undefined ,这就是第二个 console.log 输出的内容?
它返回undefined
因为基本上你的函数不会返回任何东西。
你可以例如返回一个"haha"字符串或任何你喜欢的东西。
function haha(){
console.log('haha');
return 'haha';
}
console.log(haha());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)