Answers for "check in_array in jquery"

0

array_diff in jquery

/** SUBTRACT ARRAYS **/
function subtractarrays(array1, array2){
    var difference = [];
    for( var i = 0; i < array1.length; i++ ) {
        if( $.inArray( array1[i], array2 ) == -1 ) {
                    difference.push(array1[i]);
        }
    }

    return difference;
}

var I_like    = ["love", "sex", "food"];
var she_likes = ["love", "food"];

alert( "what I like and she does't like is: " + subtractarrays( I_like, she_likes ) ); //returns "Naughty"!
Posted by: Guest on September-05-2020
0

jquery check if value is in array

$.inArray( 5 + 5, [ "8", "9", "10", 10 + "" ] );
Posted by: Guest on November-13-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language