Javascript Unique Concepts
Hello Friends, this is the first post of my first blog. Here I am going to tell you few Javascript basic concepts. 1) Remove duplicates from an Array e.g const arr = [ 1, 3, 4, 3, 5, 1 ] To remove duplicates from array arr = [ ...new Set(arr) ] // [ 1, 3, 4, 5 ] ------------------------------------------------------------------------------------------------------------------------ 2) Clone Object Method 1: const newObj = JSON.parse(JSON.stringify(obj)) Method 2: const newObj = Object.assign( {}, obj ) Method 3: const newObj = { ...obj } ------------------------------------------------------------------------------------------------------------------------ 3) Merge two arrays and create new array const arr3 = [ ...arr1, ...arr2 ] ------------------------------------------------------------------------------------------------------------------------ Thanks you for reading it out.