Lodash check value in a array case insensitive

a 夏天 提交于 2019-12-01 15:50:29

The "native" javascript (ES6) solution using Array.some() function (as an alternative):

var divisionName = "division 2",  // for example
    hasDivision = divisionList.some((obj) => obj["Name"].toLowerCase() === divisionName);

console.log(hasDivision);  // true

You can pass a function to _.some where you compare the name in case insensitive way, for example:

_.some(divisionList, function(division) {
  return division.Name.toLowerCase() === divisionName;
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!