I have the following code which I believe to be correct and transpiler ES6/Babel option on but I get the following error.
"error"
"TypeError: nums.find is not a function
at qezoze.js:11:18
at qezoze.js:16:3
at https://static.jsbin.com/js/prod/runner-3.34.2.min.js:1:13603
at https://static.jsbin.com/js/prod/runner-3.34.2.min.js:1:10524"
This is my code at JS bin (https://jsbin.com/qezoze/edit?js,console)
/*jshint esnext: true */
(function() {
'use strict';
let nums = [1,2,3,4,5];
let one = nums.find(num => num === 1);
console.log(one);
}());
JSBin is transpiling the code, but not loading the shims necessary for full support. We can see this if we inspect the document that's being run:
Note that there are no script
elements except the one with your code. While one could add to Array.prototype
from outside the window, given that nothing is set up to delay your code to give JSBin a chance to do that (and given that Array.prototype.find
is apparently actually missing), apparently they're just not including the shims.
It works on Babel's REPL.