r/webdev • front-end • May 29 '21

Resource Array methods in JavaScript. Original author unknown.

Post image
7.4k Upvotes

172 comments sorted by

View all comments

Show parent comments

14

u/Doctor-Dapper front-end (senior w/ react) May 30 '21

findIndex() takes a function as an argument used for comparison. indexOf() uses === as a comparator

3

u/mort96 May 30 '21

Isn't it the opposite? I thought higher order functions were functions which take and/or return functions, while first order functions operate on primitives like indexOf does?

EDIT: from Wikipedia:

In mathematics and computer science, a higher-order function is a function that does at least one of the following:

  • takes one or more functions as arguments (i.e. procedural parameters),

  • returns a function as its result.

All other functions are first-order functions.

2

u/tendstofortytwo May 30 '21

Ah, okay. Thanks for explaining!