Remove duplicates from an array

The expression […new Set(recordIdArray)] in JavaScript provides a simple and efficient way to remove duplicates from an array. The Set object inherently stores only unique values, so when you passrecordIdArray to new Set(), all duplicate elements are automatically filtered out. The spread operator … then converts the set back into a regular array, preserving the… Continue reading Remove duplicates from an array

Object with key value pair to Array

const RECEPIENTS = {         ‘chris’: 21661,         ‘sam’: 21628,         ‘danna’: 21629,         ‘anil’: 3,         ‘danny’: 21633,         ‘ahap’: ‘aha-shipping@airportapplaincehelp.zendesk.com’,         ‘fernanda’: 86081,         ‘laura’: ‘laura.martinez@airportappliance.com’,      … Continue reading Object with key value pair to Array

JavaScript To Find the most frequent item of an array

If we want to filter the item from the array which is frequently used then we can follow the below Example Here in the below example the array jjarray contain ‘a’ 5 times , so the most frequently item will be a. Sample array: var jjarray=[3, ‘a’, ‘a’, ‘a’, 2, 3, ‘a’, 3, ‘a’, 2,… Continue reading JavaScript To Find the most frequent item of an array

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

Remove array values

To remove values from array in js use _.reject on array. From array ‘categoryArray’ remove values equal to variable ‘hideCategory’.var categoryArray = originalRet.categories[1].categories;categoryArray= _.reject(categoryArray, function (method) { return method.text==hideCategory; });