Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript Set Difference Operation

// perform difference operation
// elements of set a that are not in set b
function difference(setA, setB) {
    let differenceSet = new Set(setA)
    for (let i of setB) {
        differenceSet.delete(i)
    }
    return differenceSet
}

// two sets of fruits
let setA = new Set(['apple', 'mango', 'orange']);
let setB = new Set(['grapes', 'apple', 'banana']);

let result = difference(setA, setB);

console.log(result);
Comment

PREVIOUS NEXT
Code Example
Javascript :: Using json_encode() function to convert an Array to a string 
Javascript :: onchange radio button jquery ajax 
Javascript :: learn nodejs 
Javascript :: getboundingclientrect 
Javascript :: use css child selector inside js 
Javascript :: get min/max array 
Javascript :: mdn includes 
Javascript :: JavaScript block-scoped Variable9 
Javascript :: vue implode array 
Javascript :: what is asynchronous in javascript 
Javascript :: react native expo flatlist 
Javascript :: js concat 
Javascript :: copy object with new property in js 
Javascript :: ? operator in js 
Javascript :: check if form bootstrap is valid js 
Javascript :: split whitespace except in quotes javascript 
Javascript :: get max height from array element jqeury 
Javascript :: add 
Javascript :: vue date filter component 
Javascript :: how to add objects in array 
Javascript :: how to append response header in node 
Javascript :: Using fetch to upload files 
Javascript :: react click outside class implementation 
Javascript :: strict mode 
Javascript :: how to pick date from datepicker in selenium 
Javascript :: javascript hoisting 
Javascript :: experss cookie session 
Javascript :: image upload using jquery ajax 
Javascript :: javascript array destructuring last element 
Javascript :: reduce method in javascript array of bjects 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =