Skip to content

Javascript – What is alternative to find function?

I am using find () function for one of my project. Official document says that Internet Explorer is not supported. What else can I use?



A polyfill is a code that provides the functionality that you normally expect the browser to provide you natively. Here is the polyfill for Array.find

if (!Array.prototype.find) {
  Array.prototype.find = function(predicate) {
    if (this === null) {
      throw new TypeError('Array.prototype.find called on null or undefined');
    if (typeof predicate !== 'function') {
      throw new TypeError('predicate must be a function');
    var list = Object(this);
    var length = list.length >>> 0;
    var thisArg = arguments[1];
    var value;

    for (var i = 0; i < length; i++) {
      value = list[i];
      if (, value, i, list)) {
        return value;
    return undefined;
User contributions licensed under: CC BY-SA
8 People found this is helpful