array.find doesn't work with Babel
jquery find in array
find json object in array by value
typescript find in array
I'm transpiling my ES2015 code using Babel. However it doesn't translate
find for Arrays. The following line throws the error
TypeError: options.find is not a function
let options = [2,23,4] options.find(options, x => x < 10)
Use babel polyfill.
require("babel/polyfill"); [1, 2, 3].find((x) => x >= 2); // => 2
See: Polyfill · Babel
Or you can use callback.
Array.find([ 1, 2, 3 ], (x) => x >= 2); // => 2
In newer versions it's
source: Babel Docs
Or if you're using ES6 imports already
Do not forget to install it:
npm i babel-polyfill.
Why array.find() is not working as expected?, find() using babel-node it works, but it doesn't work in the runtime because it doesn't proxy find to core-js . Suggestion: use _core.Array.find , but 2 The list of values in which to find it, i.e. the results of the ISNUMBER(FIND(.. array calculation 3 A number to define whether an exact or approximate match in the list is required. 0 (zero) = exact match required. The number returned by the MATCH function is then used as the row element of the INDEX function. Hope that isn't too confusing.