React JS Arrow Function

In this reactjs tutorial, we will dive into how to create an arrow function in react web app and how can use in a different situation to get an output.

The react js arrow function come with the combination of equal and greterthen sign, it can be show below like syntax:

function heelo = () => {
  //code
} 

If you want to print the name of react js developer who is developing your project that is in reactjs then you can use a function like the below example:

function printdeveloper = (name) =>{
console.log(name);
}
  
printdeveloper("blogindices");

You can use also write this function if you have one argument then:

function printdeveloper = name =>{
console.log(name);
}
  
printdeveloper("blogindices");

In the normal javascript this function write like below which is an older version of modern javascript version:

function printdeveloper(name){
console.log(name);
}
  
printdeveloper("blogindices"); 

Suppose you want to print a number then it will look like below example:


function numberprint = (number) => {
  return number * 2;
}

console.log(numberprint(2));

You can write the above example below:


function numberprint = number = number * 2;

console.log(numberprint(2));

Here you don’t need return, bracket, and braces to run the function but this is only when you have a single parameter.

Hope you are getting an idea of how to create an arrow function in reactjs and execute it. If you are looking for more React App or web tutorials then, join us on social channels and also share article links to help others.

Stay in touch. Ask Questions.
Lean on us for help, strategies and expertise.

Leave a Reply

Your email address will not be published. Required fields are marked *