Has anyone come across something like this const foo = (var1, var2) => bar
in JS. I was going through someone else's code and came across something like this, not sure what this code does exactly but the line that precedes this is a declaration for bar let bar;
. Does anyone have any ideas what this means
Asked
Active
Viewed 41 times
-2

Lonwabo Rarane
- 85
- 6
-
1It's the syntax for creating arrow functions. – Pointy Nov 23 '22 at 13:32
-
[Arrow function expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions). – Andy Nov 23 '22 at 13:32
1 Answers
-1
https://www.w3schools.com/js/js_arrow_function.asp
its for arrow functions, so you can write shorter function syntax

Delano van londen
- 398
- 1
- 19
-
1please use MDN when possible for javascript-related references, not some random webpage. – gog Nov 23 '22 at 13:39
-
1dude, its w3schools not a random webpage. but sure. ill keep it in mind – Delano van londen Nov 23 '22 at 13:40
-
Does the variable arrow mean it'll assign whatever it returns to that variable though? – Lonwabo Rarane Nov 23 '22 at 20:31