Return function is not used directly return data arrow

In MDN web document viewing Array.from use the arrows to see without the use of return in the function can return data, and return some simple methods, you can easily written.

 

Array.from() The method from a similar array or iterables create a new instance of an array of shallow copy.

the console.log (. the Array from ( ' foo ' ));
 // expected Output: the Array [ "F", "O", "O"] 

// arrow conventional writing function . the console.log (the Array from ([ . 1 , 2 , . 3 ], (X) => { return X + X})); // expected Output: the Array [2,. 4,. 6]
// arrow simple function
. the console.log (the Array from ([ . 1 , 2 , . 3 ], (X) => X + X)); // expected Output: the Array [2,. 4,. 6]

 

 When the function arrow arrow behind simple operation, directly remove the "{}", this may not be able to use the return value is returned.

Guess you like

Origin www.cnblogs.com/aidixie/p/12151534.html