ar.map() did not display Array [2,3,4] if the inside of ( ) is an Arrow function expression and there is a semicolon in the return statement. Can you point out the cause or error of this problem?
function f1(x) {return x+1;}
constar = [1,2,3];
console.log(ar.map(/*...*/));
One form of the Arrow function expression as an argument for map
param=>expression
;
is unnecessary if you use the , and the expression does not contain ;
.
;
constitutes a statement.
For example,
expression;
is a statement.
Sentences originally require ;
, but JavaScript's semicolon auto-insert feature allows many syntaxes to omit the statement ;
.So, sentence without semicolon
return expression
is no longer an error.
© 2024 OneMinuteCode. All rights reserved.