This parameter is optional. That's where the Set object comes in. Using a Set object is the easiest and speediest way to get the number of unique elements, and you can apply this method in your project to achieve your goal quickly. The Set object allows us to store data types from simple to complex in a unique and non-duplicating. (For example, the Set of [0, 0, 1, 1, 2] is [0, 1, 2] To extract only the IDs of the original array, the code looks like this (where the original array is named items ): const IDs = new Set(items.map(item => item.id)) Now we've got an array of only unique IDs. INPUT: The array elements OUTPUT: the unique elements of the array PROCESS: Step 1: [Taking inputs from the user] Read n [number of elements] For i = 0 to n-1 repeat Read a [i] [End of 'for' loop] Step 2: [Finding the unique elements] For i=0 to n-1 repeat Set c<-0 For j=0 to i-1 repeat If a [i]=a [j] then Set c<-c+1 [End of 'if'] [. Let's look at two ways to use iteration to get the unique values in a list, starting with the more verbose one. (Thats because .length is a method on arrays, not sets.). This example uses the filter method which checks the index of elements varies for elements any element and returns elements. I have two arrays in javascript -: var array1 = ['12','1','10','19','100']; var array2 = ['12','10','19']; I need to a method to get the unique from two arrays and put them in array3 Array3 should be -: var array3 = ['1','100']; Thanks for help. Method 2: Traverse the array and insert the array elements and their number of occurrences in the hash table. That wont quite work, because Sets and arrays in JavaScript are not the same thing! Secondly by passing an array to the constructor ( new Set () ): let arraySet1 = new Set( [3,2,1]); // Set (3) {3, 2, 1} Duplicated values are also removed if they are included in the initial array: This was an issue because the ID numbers were being used for setting the HTML ids in a form; that meant some of the