Reputation: 21
l = (m, n) => { if (w()) return n-1;}
is one of a sample code but I want to understand the use of this in a JavaScript I have a long code which has most use of these elements can anyone help me out on this really confused on this part.
I have tried on https://www.w3schools.com/js/js_arrow_function.asp but could not get exact answers.
I have tried on some forums too but the exact search results could not be fetched.
Upvotes: 0
Views: 128
Reputation: 2143
=>
stands for arrow function which was introduced in ES6.
So instead of typing below syntax for writing function:
function test(m, n) {
if (w()) return n-1;
}
The same can be written using arrow function:
(m, n) => {
if (w()) return n-1;
}
In your code snippet, variable l
is assigned the value of above function.
Your function will return n-1
based on the return of another function w()
.
Upvotes: 1