While I am writing some JavaScript, I came across a new code "indexOf". After read another post I thought its behaviour is as shown below but it seems not true. Can someone kindly give me an explanation about "indexOf", please?
false = -1;
true = 0 and more?
I have tried to change -1 to 0 and more but then nothing happens. Just to have a better understanding about jquery/indexOf.
what I have now,
$(this).closest(row)[td_word.indexOf(keyword) !== -1 ? 'show' : 'hide']();
it search for match(es) of "keyword" from "td_word",
if it is not false (!== -1, thus true) display:visible;,
if it is not true (false) display:hide;.
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…