Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 6
    In addition to behavioral changes like the one you describe above, exposing internal parameters in the signature also tends to confuse consumers of the function; such parameters are often exposed to the programmer by their IDE. Commented Sep 4, 2020 at 14:26
  • using array.map(someFunction) is javascript is generally an antipattern - and should not be used. For example, ["1","2","3"].map(parseInt) returns [1, NaN, NaN]. Commented Sep 4, 2020 at 17:37
  • Thinking about it, the parseInt function is really similar to the isPalindrome function as it takes in an optional parameter with a default value as the second argument. Despite the "unusual" behavior when using map, parseInt is still part of the standard library. In addition, map passes 3 parameters, not 2, which while you didn't touch on it in your answer, if you're going to pass a function like that you need to know and have the number of arguments memorized. Commented Sep 4, 2020 at 17:43
  • @CarsonGraham: Would you avoid array.map(someFunction) even if someFunction is documented to be usable that way? Commented Sep 4, 2020 at 17:50
  • @CarsonGraham No, that's not an antipattern. The real problem is that the javascript standard library is full of antipatterns and nasty surprises. Commented Sep 9, 2020 at 19:24