我有一个字符串(名称)数组,例如:
name =["John Doe","Lutfur Kabir", "Moshiur Imtiaz Rahman", "Clark Kent","Jenny Doe"]
我想获取其中包含Doe的名称的索引。如何使用JavaScript进行操作。
答案 0 :(得分:0)
答案 1 :(得分:0)
您可以使用Array.prototype.includes
:
Find the previous answer here already
var categoriesPresent = ['word', 'word', 'specialword', 'word'];
var categoriesNotPresent = ['word', 'word', 'word'];
var foundPresent = categoriesPresent.includes('specialword');
var foundNotPresent = categoriesNotPresent.includes('specialword');
console.log(foundPresent, foundNotPresent); // true false