hello = function() {
return "Hello World!";
}
⮟
hello = () => {
return "Hello World!";
}
⮟
hello = () => "Hello World!";
"If the function has only one statement, and the statement returns a value, you can remove the brackets and the return keyword"
"This works only if the function has only one statement."
hello = (val) => "Hello " + val;
If you have parameters, you pass them inside the parentheses
hello = val => "Hello " + val;
if you have only one parameter, you can skip the parentheses as well
No comments:
Post a Comment