Array Merge/ Combine in JS

Merge without removing duplicate elements -> Using concat() Method: The concat() method accepts arrays as arguments and returns the merged array. // with elements of nums1 and returns the // combined array – combinedSum arraylet combinedNums = nums1.concat(nums2, nums3);// More readable formlet combinedNums = [].concat(nums1, nums2, nums3); -> Using spread operator: Spread operator spreads the value of the array into… Continue reading Array Merge/ Combine in JS

Map in JavaScript

In JavaScript, a Map is a built-in object that allows you to store key-value pairs, similar to an object. However, a Map offers some additional functionality that makes it useful in certain situations. Here’s an example of creating a Map: To add a key-value pair to the Map, you can use the set() method: You… Continue reading Map in JavaScript

Set in JavaScript

In JavaScript, a Set is a collection of unique values of any type, which means that each value can occur only once in the Set. It can be used to store a collection of values without any duplication. To create a Set in JavaScript, we use the Set() constructor or the Set literal notation by… Continue reading Set in JavaScript