Blogger Information
Blog 7
fans 0
comment 0
visits 2346
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
函数的四种形式
东风又西风
Original
592 people have browsed it

函数类型

命名函数

function name (){console.log(‘hello,world’)}

其中的“name”为函数名称,()内为外部可传入的参数 {}内为函数代码。
命名函数不受上下问约束。

匿名函数

const name = function(){console.log(‘hello,world’)}

和命名函数基本相同。但是受到上下文约束

箭头函数

let name=()=>console.log(‘hello,world)

匿名函数的简化。只有一个参数时可省略()
但有多个或没有参数的时候必须加上()

立即执行函数

(let name=(a,b)=>${a}+${b}=(a+b))(2.3)

立即实行函数是在函数后立即传参,传参后就可以执行。

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!