That reminds me of that post about things we always google. One of mine always seems to be the param order for the callback passed to Array.prototype.map().
Param order can definitely get you. But I'm now glad to have hints in both Atom and VS Code about what the next param is expected to be -- at least if the function is defined in the code, or is a native member of the language.
I don’t have a nice pneumonic to help but I realized one day that map, forEach, and a few others all have the same callback Parma order of value, index, array
I kept flipping index and value (and forgetting about array, honestly). But that order does make a lot more sense since the index and array aren't needed for everything.
Thanks for mentioning that by the way. I guess they would've done that for consistency and ease of use.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That reminds me of that post about things we always google. One of mine always seems to be the param order for the callback passed to
Array.prototype.map()
.Param order can definitely get you. But I'm now glad to have hints in both Atom and VS Code about what the next param is expected to be -- at least if the function is defined in the code, or is a native member of the language.
I don’t have a nice pneumonic to help but I realized one day that
map
,forEach
, and a few others all have the same callback Parma order ofvalue
,index
,array
I kept flipping
index
andvalue
(and forgetting aboutarray
, honestly). But that order does make a lot more sense since theindex
andarray
aren't needed for everything.Thanks for mentioning that by the way. I guess they would've done that for consistency and ease of use.