Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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"!
Comment

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"!
Comment

PREVIOUS NEXT
Code Example
Javascript :: ajax file form 
Javascript :: immediately invoked function expression async 
Javascript :: unwind check after null or undefined 
Javascript :: moment js get date 1 month 
Javascript :: set css var with javascript 
Javascript :: js remove value input 
Javascript :: react js download file 
Javascript :: express js url with id 
Javascript :: recursion javascript 
Javascript :: javascript initialize array 
Javascript :: js if array is 2d 
Javascript :: add new items in a select input using js 
Javascript :: force rerender react 
Javascript :: timeout httppost angular 
Javascript :: delete element in hash in javascript 
Javascript :: ajax current url 
Javascript :: node require module 
Javascript :: webpack env argument 
Javascript :: javascript format date to dd-mm-yyyy 
Javascript :: how to check input is selected or not 
Javascript :: laravel send http post request json 
Javascript :: find highest value in array javascript 
Javascript :: find from string in javascript 
Javascript :: print all days names of a month 
Javascript :: Execute JavaScript using Selenium WebDriver in C# 
Javascript :: prettier vscode settings 
Javascript :: javascript json deserialize 
Javascript :: how set defualt image for dropify 
Javascript :: how to get common elements from two array in javascript using lodash 
Javascript :: how to remove a specific element from array in javascript 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =