1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| /* function show(){ return 1; } alert(show()); */ var show=()=>'welcome'; alert(show()); ```
### 带参数的形式
```bash /* function show(a){ return a; } alert(show(12)); */
/* var show=(a,b)=>a+b; alert(show(12,5)); */ /* function rnd(n,m){ return Math.floor(Math.random()*(m-n))+n; } alert(rnd(12,90)); */ //箭头函数的形式 let rnd=(n,m)=>Math.floor(Math.random()*(m-n))+n;
alert(rnd(10,40));
|