https://wesbos.com/arrow-functions/
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions#
const implicit = (a) => {
a = a + 1;
return a;
}
const implicitX = x => x = x + 1;
const implicit = (a) => {
a = a + 1;
let b = a * a;
return b;
}
const implicitY = y => y = (y + 1) * (y + 1);
implicitY(2);
// 9
/* 当删除大括号时,它将是一个隐式的返回值,这意味着我们不需要指定我们返回*/
const implicitA = y => {y = (y + 1) * (y + 1);};
implicitA(2);
// undefined
/* 当有大括号时,我们需要指定返回一个显示的返回,*/
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions#
// 如果箭头函数 有多个参数, 必须使用 ()圆括号:
const multi_params = (a, b) => {
let sum = a + b;
console.log(sum);
};
multi_params(1, 2);
// 3
// 如果箭头函数 无参数, 必须使用 ()圆括号或者 _下划线:
_ => { statements; }
const multi_X = _ => {
let sum = a + b;
console.log(sum);
};
multi_X(1, 2);
// Uncaught ReferenceError: a is not defined
ECMA 262 6th
https://cdn.xgqfrms.xyz/offical-docs/ECMA/ECMA-262%206th%20edition%20June%202015.pdf