JavaScript Arrow 箭头函数ES6 中引入了箭头函数。箭头函数允许我们编写更短的函数 语法: 之前: hello = function() { return "Hello World!";} 亲自试一试 » 用了箭头函数之后:hello = () => { return "Hello World!";} 亲自试一试 » 确实变短了!如果函数只有一个语句,并且该语句返回一个值,则...
Arrow Function With Parameters: hello = (val) =>"Hello "+ val; Try it Yourself » In fact, if you have only one parameter, you can skip the parentheses as well: Arrow Function Without Parentheses: hello = val =>"Hello "+ val; ...