Javascript array find alternative -


i'm looking alternative find() method of array. i'm using on android browser , array.prototype.find() doesn't work there. definition array support

var test= this.arrayofvalues.find(function (value) {             return (value.name === device.value) }); 

if not care programming own, , if indexof somehow not usable, have @ underscore.js#find. alternative, @ninascholz recommended in comments, use polyfill mozilla.org:

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 function');     }     var list = object(this);     var length = list.length >>> 0;     var thisarg = arguments[1];     var value;      (var = 0; < length; i++) {       value = list[i];       if (predicate.call(thisarg, value, i, list)) {         return value;       }     }     return undefined;   }; } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -