|
|
|
|
|
by mbel
3115 days ago
|
|
Fat arrow is used to define a lambda function. The left-hand side of the arrow is argument list (_ is used to indicate lack of used arguments) and the right-hand side is the function body. It is equivalent to: var currentUrl = function () { return window.location.href; }
|
|
Note that this is a convention, not a requirement for the syntax (like in some other languages).
I've spent at least a few mins troubleshooting why `_.map` (from `lodash` npm module) didn't work inside of a fat function while fixing another developer's defect.
If you use `_` as a valid const/variable identifier anywhere in your codebase, I would recommend you ditch `_ => alert(1)` for something more obscure like `ΓΈ => alert(1)`