小编Ale*_*ruz的帖子

如何在字符串上执行"like"或"contains"搜索?

我可以在if()条件中比较数组的特定值吗?

例:

// teacher object
function Prof(id,tab,nome,ocupacao,email,tel,foto)
{
   this.id  = id;
   this.tab = tab;
   this.nome    = nome;
   this.ocupacao= ocupacao;
   this.email   = email;
   this.tel = tel;
   this.foto    = foto;
}

//teachers array
var arr = new Array();
arr[0]  = new Prof('pf1','dir','Mario','Diretor','mail@mail.com','tel','foto');
arr[1]  = new Prof('pf2','dir','Joao','t1 t3 t7','...','...','...');
...

// So now i will get the array value of "ocupacao" and see if this value has
// an specific value that i´ve defined in the conditional:
...
if(arr[i].ocupacao (has value) t7)
{ …
Run Code Online (Sandbox Code Playgroud)

javascript

1
推荐指数
1
解决办法
886
查看次数

标签 统计

javascript ×1