How to pass parameter values in the javascript arrow function?
How to pass parameter values in javascript arrow function?
287
08-Oct-2023
Updated on 11-Oct-2023
Aryan Kumar
11-Oct-2023In JavaScript, arrow functions are a concise way to create functions, and they can accept parameters just like regular functions. You can pass parameter values to arrow functions by specifying them in the parentheses that follow the arrow symbol (=>). Here's the basic syntax for creating arrow functions with parameters:
Here's an example of an arrow function with parameters:
In this example, the add arrow function accepts two parameters, a and b, and returns their sum.
You can also create arrow functions with a single parameter without using parentheses, like so:
Here's an example:
Arrow functions are commonly used for shorter, concise functions and are particularly useful for functions where you need to pass parameters or return values quickly.