DEV Community

loading...

Writing Arrow Functions with Parameters

rthefounding profile image Randy Rivera ・1 min read
  • 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.
Enter fullscreen mode Exit fullscreen mode
  • It is possible to pass more than one argument into an arrow function.
const myConcat = (arr1, arr2) => arr1.concat(arr2);
Enter fullscreen mode Exit fullscreen mode
console.log(myConcat([1, 2, 3,], [4, 5])); will display [1, 2, 3, 4, 5]
Enter fullscreen mode Exit fullscreen mode
  • 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.

Discussion (0)

Forem Open with the Forem app