只有一個(gè)參數(shù)的簡(jiǎn)單函數(shù)
{
let single = a => a;
console.log(single('Hello,World'));
}
沒有參數(shù)的函數(shù)
{
let single = () => console.log('no param');
single();
}
說明:
- 需要在箭頭前加上小括號(hào)
多個(gè)參數(shù)
{
let add = (a, b) => {
return a+b;
}
console.log(add(5, 10));
}
說明:
- 用小括號(hào)括起來,參數(shù)間用逗號(hào)分隔
- 當(dāng)函數(shù)體內(nèi)有多條語(yǔ)句時(shí)舅巷,需要用大括號(hào)包起來