Difference Between Normal Function and Arrow Function
- Arrow Function is like the Shortcut for Creating Normal Function.
- In Arrow Function code looks cleaner as compared to Normal Function.
We will Compare the syntax of both function Normal Function and Arrow Function
Normal Function :
We have Created a variable with name returnedValue and parsing parameters in place of parameters and variableName is the Returned Value.
Lets See Some Examples To make it clear.
Lets Make a program that calculates the percentage of 5 Marks out of 100.
First in Normal Function :
Now do it with Arrow Function :
We have created a let variable, and have Defined function in it.
We are sending 4 Variables m1, m2 , m3 , m4 , m5
Then, we have used formula to calculate the percentage : ((sum of all marks / Total Marks)*100)
The value of result will be printed in Console Tab.