Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

sort javascript number array with duplicates

//ascending order
console.log([1, 2, 0, 1].sort((a, b) => a - b))

//descending order
console.log([1, 2, 0, 1].sort((a, b) => b - a))
 Run code snippetHide results
Comment

duplicate numbers in an array javascript

[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]
Comment

PREVIOUS NEXT
Code Example
Javascript :: get date in javascript 
Javascript :: @angular/common@11.2.1 node_modules/@angular/common @angular/common@"11.2.1" from the root project 
Javascript :: javascript wait for dom 
Javascript :: jquery telephone input mask 
Javascript :: nodejs request 
Javascript :: javascript date to firebase timestamp 
Javascript :: delete with body angular 
Javascript :: pass variable to regrex literal notation javascript 
Javascript :: add a Google Font to a VueJS 
Javascript :: regular expression to remove underscore from a string javascript 
Javascript :: get unique array javascript 
Javascript :: react best libraries for Modern UI 
Javascript :: javascript sort numbers 
Javascript :: useeffect clearinterval loading 
Javascript :: install ckeditor 5 for react js 
Javascript :: express public folder 
Javascript :: react native floating button 
Javascript :: remove line break javascript 
Javascript :: how to scroll to an element javascript react 
Javascript :: JS automate a click 
Javascript :: merge objects javascript 
Javascript :: jquery get by name 
Javascript :: how to drop collection in mongoose 
Javascript :: jquery attr 
Javascript :: js read text file line by line 
Javascript :: How to get the Class Name of an Object in JavaScript 
Javascript :: math.floor js 
Javascript :: js copy to clipboard 
Javascript :: First non repeating character position in a string 
Javascript :: include other js files in a js file 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =