Here’s a much cleaner solution for ES6 that I see isn’t included here. It uses the Set and the spread operator: ...
var a = [1, 1, 2];
[... new Set(a)]
Which returns [1, 2]
More Related Contents:
- How to dectect objects' overlaping situations in javascirpt? [closed]
- Turning live() into on() in jQuery
- jQuery/JavaScript collision detection
- Parsing JSON objects for HTML table
- How do I create dynamic variable names inside a loop?
- Why is it a bad practice to return generated HTML instead of JSON? Or is it?
- How to connect HTML Divs with Lines? [duplicate]
- Need to cancel click/mouseup events when double-click event detected
- How to uncheck checked radio button [duplicate]
- How to blur the div element?
- How to Compare two Arrays are Equal using Javascript? [duplicate]
- What are techniques to get around the IE file download security rules?
- javascript: detect scroll end
- Get the DOM path of the clicked
- window.focus(), self.focus() not working in firefox
- Can javascript access iframe elements from the parent page?
- jquery: unload or beforeunload?
- Open infoWindows from an external link outside of the google map
- Sorting of jqGrid (v4.1.2) treegrid not working with Ajacency Model
- Get the offset position of the caret in a textarea in pixels [duplicate]
- jQuery keyboard events
- Chain ajax and execute it in sequence. Jquery Deferred
- Prevent iOS bounce without disabling scroll ability
- How do I make an area unclickable with CSS?
- ToggleClass animate jQuery?
- Javascript – Leading zero to a number converting the number to some different number. not getting why this happening?
- How to flatten array in jQuery?
- how to use html2canvas and jspdf to export to pdf in a proper and simple way
- Capturing result of window.onbeforeunload confirmation dialog
- Can you have multiple lines in an element?