javascript - jQuery $.inArray() returns 0 -


if have array ('a', 'b') , check $.inarray('a', thearray); index, 0, , false. need check result further , it's annoying...

is there quick method trough can true/false, , not indexes?

basically have string in html5 data attribute: data-options="a,b,c" , 3 a, b, c variables in javascript must take true/false values based on what's inside data-options...

you can achieve invoking binary not operator.

if( ~$.inarray('a', thearray) ) { } 

explained in detail here: typeofnan.blogspot.com/2011/04/did-you-know-episode-ii.html


Comments

Popular posts from this blog

Python __call__ special method practical example -

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -