Javascript Arrow Function 2

Source: Internet
Author: User

No parameter amount arrow function

If the function does not have arguments, we can say by (), is not some force lattice, see example

Const FULLNAMES5 = Names.map (() = ' Cool Bos '); Console.log (FULLNAMES5); Cool Bos, cool Bos, cool BOS

There is another way to do this is to use the underscore _ instead of ()

Names.map (_=> ' Cool Bos ');

Of course, this underline doesn't make any sense, you can do it, but it doesn't mean anything.

Names.map (x = ' cool bos '), names.map (Wesbos = ' cool Bos '), names.map (_ya___yayayayay = ' cool bos '); Names.map ( Do_yaget_the_point = ' Cool Bos ');

An arrow function is an anonymous function

Look at a function with a name saymyname.

function Saymyname (name) {  alert (' Hello ${name} ');}

  

A named function is handy for coder to find errors and clear functions.

But the arrow function is an anonymous function, what should I do? We can use a variable, for example:

Const SAYMYNAME = (name) + {alert (' Hello ${name}! ')}saymyname (' Wes ');

  

If you think this article is good, want to give Kumaji (Li Ming) to reward?

Javascript Arrow Function 2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.