Answers for "javascript compare function"

0

string comparison in javascript

var str1 = "ab";
var str2 = "ab";
var n = str1.localeCompare(str2);
Posted by: Guest on April-06-2021
3

sort js

numArray.sort((a, b) => a - b); // For ascending sort
numArray.sort((a, b) => b - a); // For descending sort
Posted by: Guest on October-20-2020
2

javascript sort function

var points = [40, 100, 1, 5, 25, 10];
points.sort((a,b) => a-b)
Posted by: Guest on May-08-2020
-1

string comparison in javascript

console.log("10" == "10"); //True
console.log(parseInt(10) == 10); // True Best practice
Posted by: Guest on December-06-2020

Browse Popular Code Answers by Language