🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to JavaScript Notes
Topic #72

JS Set Logic

Col 1
Logic Set Methods In JavaScript 2025, 7 new logical methods were added to the Set object: union() difference() intersection() isDisjointFrom() isSubsetOf() isSupersetOf() symmetricDifference()

Browser Support

Set Logic is an ECMAScript 2025 feature.

JavaScript 2025 is fully supported in all modern browsers since May 2025:


The union() Method

The union() method returns the union of two sets.

The union() method returns a new set containing the elements which are in this set, or in the argument set, or in both:

Example

const A = new Set(['a','b','c']);

const B = new Set(['b','c','d']);

const C = A.union(B);

The intersection() Method

The intersection() method returns the intersection of two sets.

The intersection() method returns a new set containing the elements which are in this set and in the argument set:

Example

const A = new Set(['a','b','c']);

const B = new Set(['b','c','d']);

const C = A.intersection(B);

The difference() Method

The difference() method returns the difference between two sets.

The difference() method returns a new set containing elements which are in this set but not in the argument set:

Example

const A = new Set(['a','b','c']);

const B = new Set(['b','c','d']);

const C = A.difference(B);

The symmetricDifference() Method

The symmetricDifference() method returns the symmetric difference between to sets.

The symmetricDifference() method returns a new set containing elements which are in this set or in the argument set, but not in both:

Example

const A = new Set(['a','b','c']);

const B = new Set(['b','c','d']);

const C = A.symmetricDifference(B);

The isSubsetOf() Method

The isSubsetOf() method returns true if all elements in this set is also elements in the argument set:

Example

const A = new Set(['a','b','c']);

const B = new Set(['b','c','d']);

let answer = A.isSubsetOf(B);

The isSupersetOf() Method

The isSupersetOf() method returns true if all elements in the argument set are also in this set:

Example

const A = new Set(['a','b','c']);

const B = new Set(['b','c','d']);

let answer = A.isSupersetOf(B);

The isDisjointFrom() Method

The isDisjointFrom() method returns true if this set has no elements in common with the argument set:

Example

const A = new Set(['a','b','c']);

const B = new Set(['b','c','d']);

let answer = A.isDisjointFrom(B);

Note: Learn More: JavaScript Sets JavaScript Set Methods JavaScript Weak Sets JavaScript Set Reference JavaScript Maps

Want to go beyond the notes?

Join CodingNow 2.0's JavaScript course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

JS Set Logic – FAQs

Quick answers about learning JS Set Logic in JavaScript.

This free note from CodingNow 2.0 explains JS Set Logic in JavaScript — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every JavaScript topic on CodingNow 2.0, including JS Set Logic, is 100% free with no signup required.
With focused practice, most students grasp JS Set Logic in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now