Writing Arrow Functions with Parameters

Just like a regular function, you can pass arguments into an arrow function.

const double = (item) => item * 2;
double(4);
double(4) would return the value 8.

It is possible to pass more than one argument into an arrow function.

cons…


This content originally appeared on DEV Community and was authored by Randy Rivera

  • Just like a regular function, you can pass arguments into an arrow function.
const double = (item) => item * 2;
double(4);
double(4) would return the value 8.
  • It is possible to pass more than one argument into an arrow function.
const myConcat = (arr1, arr2) => arr1.concat(arr2);
console.log(myConcat([1, 2, 3,], [4, 5])); will display [1, 2, 3, 4, 5]
  • Note:Java string concat() method concatenates multiple strings. This method appends the specified string at the end of the given string and returns the combined string. We can use concat() method to join more than one strings.


This content originally appeared on DEV Community and was authored by Randy Rivera


Print Share Comment Cite Upload Translate Updates
APA

Randy Rivera | Sciencx (2021-04-25T22:06:48+00:00) Writing Arrow Functions with Parameters. Retrieved from https://www.scien.cx/2021/04/25/writing-arrow-functions-with-parameters/

MLA
" » Writing Arrow Functions with Parameters." Randy Rivera | Sciencx - Sunday April 25, 2021, https://www.scien.cx/2021/04/25/writing-arrow-functions-with-parameters/
HARVARD
Randy Rivera | Sciencx Sunday April 25, 2021 » Writing Arrow Functions with Parameters., viewed ,<https://www.scien.cx/2021/04/25/writing-arrow-functions-with-parameters/>
VANCOUVER
Randy Rivera | Sciencx - » Writing Arrow Functions with Parameters. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/25/writing-arrow-functions-with-parameters/
CHICAGO
" » Writing Arrow Functions with Parameters." Randy Rivera | Sciencx - Accessed . https://www.scien.cx/2021/04/25/writing-arrow-functions-with-parameters/
IEEE
" » Writing Arrow Functions with Parameters." Randy Rivera | Sciencx [Online]. Available: https://www.scien.cx/2021/04/25/writing-arrow-functions-with-parameters/. [Accessed: ]
rf:citation
» Writing Arrow Functions with Parameters | Randy Rivera | Sciencx | https://www.scien.cx/2021/04/25/writing-arrow-functions-with-parameters/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.