Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript Set Subset Operation

// perform subset operation
// true if all elements of set b is in set a
function subset(setA, setB) {
    for (let i of setB) {
        if (!setA.has(i)) {
            return false
        }
    }
    return true
}

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

let result = subset(setA, setB);

console.log(result);
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript remaining elements of an array to a variable using the spread syntax 
Javascript :: javascript for...of with Sets 
Javascript :: convert dom object to string 
Javascript :: freecodecamp javascript basic step quoting string 
Javascript :: javascript variable name arguments and eval are not allowed 
Javascript :: how to locate an object with a spcific key in js array 
Javascript :: JavaScript HTML DOM Collections 
Javascript :: actionscript round roundnumber 
Javascript :: get max type value in solidity 
Javascript :: datatable all items in one line 
Javascript :: circular object array 
Javascript :: fingerprint 
Javascript :: roman to integer fastest way 
Javascript :: adding transition to collapse button js 
Javascript :: phaser rotate around distance 
Javascript :: phaser animation on start event 
Javascript :: Horizontal scroll to anchor 
Javascript :: axios imgbb 
Javascript :: react native bootsplash generate splash 
Javascript :: show a variable value in an html webpage using dom javascript 
Javascript :: nodelist example 
Javascript :: js function expression 
Javascript :: how to make a string in javascript 
Javascript :: npm read email 
Javascript :: anonymous function 
Javascript :: multer 
Javascript :: javascript map with arrow function 
Javascript :: js random seed 
Javascript :: Difference Between for...of and for...in Statement 
Javascript :: hrtime to milliseconds 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =