コールバック関数は最強
コード some ※OR条件
process.stdin.resume();
process.stdin.setEncoding('utf8');
var data = [3, 5, 4, 2, 7];
var search_1 = [1,6];
var search_2 = [1,3];
var search_3 = [2,7];
var search_4 = [2];
var result = search_1.some((v) => data.includes(v));
console.log(result);
var result = search_2.some((v) => data.includes(v));
console.log(result);
var result = search_3.some(function(v){return data.includes(v)});
console.log(result);
var result = search_4.some(function(v){return data.includes(v)});
console.log(result);
結果
false
true
true
true
コード every ※AND条件
var arr = [3, 5, 8];
var item_1 = [3,5];
var item_2 = [1,5];
var item_3 = [5];
var result = item_1.every(function(v){return arr.includes(v)});
// ↓これでもOK
console.log(result);
var result = item_2.every((v) => arr.includes(v));
console.log(result);
var result = item_3.every((v) => arr.includes(v));
console.log(result);
結果
true
false
true