84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
The new ES6 arrow functions say that in some cases, return is implicit:
return
This expression is also the implicit return value of the function.
In what situations do I need to use return in an ES6 arrow function?
I understand this rule of thumb...
The candidates are:
// 平方根 value => Math.sqrt(value) // 求和 (a,b) => a+b
For other operations (if multiple lines of code are required, an explicit return value is required)
Jackson partiallyanswered this questionin a similar question:
I would like to add the definition ofblock:
Example:
// 返回:undefined // 解释:一个空的带有隐式返回的块 ((name) => {})() // 返回:'Hi Jess' // 解释:没有块意味着隐式返回 ((name) => 'Hi ' + name)('Jess') // 返回:undefined // 解释:块内需要显式返回,但是缺少了 ((name) => {'Hi ' + name})('Jess') // 返回:'Hi Jess' // 解释:块内有显式返回 ((name) => {return 'Hi ' + name})('Jess') // 返回:undefined // 解释:一个包含单个标签的块。没有显式返回。 // 更多信息:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label ((name) => {id: name})('Jess') // 返回:{id: 'Jess'} // 解释:隐式返回表达式 ( ),其求值为一个对象 ((name) => ({id: name}))('Jess') // 返回:{id: 'Jess'} // 解释:块内有显式返回对象 ((name) => {return {id: name}})('Jess')
I understand this rule of thumb...
The candidates are:
For other operations (if multiple lines of code are required, an explicit return value is required)
Jackson partiallyanswered this questionin a similar question:
I would like to add the definition ofblock:
Example: