我需要检查主数组中是否存在特定值。
var hideFilters = function() {
var listCategoryId = ['1000014', '1000015', '1000016', '1000017', '1000018', '1000019', '1000021', '1000086'];
var actualCategoryId = '1000018';
if (actualCategoryId === listCategoryId) {
console.log('is equal');
} else {
console.log('fuen... fuen...');
}
};
hideFilters();
最佳答案
if(listCategoryId.indexOf(actualCategoryId) != -1) {
console.log('exists')
}
关于javascript - 检查数组中是否存在某个项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40933595/