JS Part3
1. filter (concise): const number = [1,2,3,3,4,4,5,6,7,8,9] const unique = number.filter((item,index)=>(number.indexOf(item)= = = index) ); filter will always return new array. It will not modify exixting array. isBiggerThanFive is the inline callback function number.filter(isBiggerThanFive); function isBiggerThanFive(n){ return n>5; } In callback function we can test the conditions and return the callback. 2. map (ES6 --includes) We can use any type of key and values const myMap = new Map() // empty map object console.log(myMap) const key1 = 'mystr' const key2 = {} const key3 = function(){} string map values myMap.set(key1, 'this is a string'); myMap.set(key2, 'This is a blank object'); myMap.set(key3, 'this is empty function') console.log(myMap); // getting a values from map let value1 = myMap.get(key1); console.log(value1); //get the size of the map console.log(myMap.size); you can loop using for of to get keys and values for(let[key,value] ...