[英]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.