findIndex() method issue with internet explorer
So my question is how can i do differently to get my index for every browser ?
You have at least three options:
Shim
Array#findIndex
; MDN has a shim/polyfill you can use.Use something else that IE11 has, such as
Array#some
(which even IE9 has):var index = -1; items.some(function(el, i) { if (el.name == paramProgramName) { index = i; return true; } });
Use something else that even IE8 has, such as
for
:var index = -1; for (var i = 0; i < items.length; ++i) { if (items[i].name == paramProgramName) { index = i; break; } }
you can use http://underscorejs.org/,
how to use:
var index = _.findIndex(objects, function(item){
return item.name == programName;
});