合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
| 检查数组中是否存在某个值 | in_array() | | --- | --- | ``` /** * [in_array 检查数组中是否存在某个值] * @param {[type]} search [待搜索的值] * @param {[type]} array [这个数组] * @return {[type]} [如果存在返回true,否则返回false] */ function in_array(search,array){ for(var i in array){ if(array[i]==search){ return true; } } return false; } ``` 案例 ``` var operator = { 'eq': '等于', 'neq': '不等于', 'gt': '大于', 'egt': '大于等于', 'lt': '小于', 'elt': '小于等于', 'like': '模糊查询', 'between': '区间查询', 'not between': '不在区间', 'in': 'IN 查询', 'not in': '不在 IN 查询', 'null': '为空', 'not null': '不为空', }; console.log(in_array('等于', operator)) #输出true ```