Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

set javascript

// Use to remove duplicate elements from the array 

const numbers = [2,3,4,4,2,3,3,4,4,5,5,6,6,7,5,32,3,4,5]

//spreading numbers of the object into an array using the new operator
console.log([...new Set(numbers)]) 

// [2, 3, 4, 5, 6, 7, 32]
Comment

js set

// Use to remove duplicate elements from the array 

const array = [2,3,4,4,2,3,3,4,4,5,5,6,6,7,5,32,3,4,5]

//spreading numbers of the object into an array using the new operator
console.log([...new Set(array)]) 

// [2, 3, 4, 5, 6, 7, 32]
Comment

JavaScript Sets

// Create a Set
const letters = new Set();

// Add Values to the Set
letters.add("a");
letters.add("b");
letters.add("c");
Comment

js Set

const id = new Set();

id.add(1);
id.add(2);
id.add(3);
id.add(3);// duplicate value will not be added
console.log(id);// output: Set {1, 2, 3}
id.delete(2);// delete the value 2 from the set
console.log(id);// output: Set {1, 3}
id.has(2);// check if the set has the value 2 // output: true
console.log(id);


//order is not guaranteed
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native add bottom tab and drawer menu 
Javascript :: nodejs request post 
Javascript :: v-bind shorthand 
Javascript :: nodejs send download file from buffer 
Javascript :: unregister react hook form 
Javascript :: myFunction with param on addEventListner 
Javascript :: xml vs json 
Javascript :: Redirect user when JavaScript is disabled with noscript 
Javascript :: MaterialRippleLayout dependency 
Javascript :: javascript check if it has passed midnight 
Javascript :: Create a Counter Object or Map in javascript 
Javascript :: apply() js 
Javascript :: NodeJS router model 
Javascript :: usenavigate and uselocation in react 
Javascript :: append item in treeview vuetify 
Javascript :: generate svg from javascript 
Javascript :: monaco editor no numbers 
Javascript :: how to remove an item from an array in javascript 
Javascript :: vuejs copy to clipboard 
Javascript :: Material-ui wallet icon 
Javascript :: Get the language of a user 
Javascript :: ABORT CONTROLLER WITH ASYNC USEEFFECT REACT 
Javascript :: display object in array 
Javascript :: how to add a class in classlist and remove after 100 ms using jquery 
Javascript :: webpack dev srcipt 
Javascript :: string contains js 
Javascript :: javascript unary plus and negation operators 
Javascript :: html2canvas not getting image if file field src is url 
Javascript :: mock function jest 
Javascript :: how to hide a screen from drawer in react navigation 5 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =