adding and deleting multiple elements through javascript and localstorage

So i am using localStorage to add buttons to my html page. When the button is clicked, i want the corresponding entry of localStorage to be deleted. My code so far: for(let i=0;i<localStorage.length;i++) { var rem=document.createElement(“button”); rem.innerHTML='<i class=”fa fa-trash-o” aria-hidden=”true”></i>’; rem.setAttribute(‘background-color’,’white’); rem.setAttribute(‘id’,localStorage.key(i)); rem.setAttribute(‘class’,’delbuttons’); document.body.appendChild(rem); } So if a button with a particular id is clicked,…

What’s the most elegant way in ES6 to filter out duplicates in an array in Javascript

I’ve seen alot of answers to this topic but I’m not completely satisfied. The snippet I liked the most was this one: [ [“1”, “2”], [“1”, “2”, “3”], [“1”, “2”] ] .filter( (path: string[], i: number, array: string[][]) => _.findIndex(array, x => _.isEqual(x, path)) === i ) This works but I find it waaaayy too…