[英]arrow function returns the function text and not the result (javascript)
箭头函数返回函数文本-“(n)=> 5 + n”,而不返回结果(6)。 我究竟做错了什么?
let n = 1;
let newText = (n) => 5 + n;
document.write(newText);
您没有在调用该函数:
document.write(newText(42));
顺便说let
,这与=>
或let
无关:
function newText(n) { return 5 + n; }
document.write(newText);
有同样的问题。
调用函数
document.write(newText(5));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.