string comparison in javascript
var str1 = "ab";
var str2 = "ab";
var n = str1.localeCompare(str2);
string comparison in javascript
var str1 = "ab";
var str2 = "ab";
var n = str1.localeCompare(str2);
javascript sort
var names = ["Peter", "Emma", "Jack", "Mia", "Eric"];
names.sort(); // ["Emma", "Eric", "Jack", "Mia", "Peter"]
var objs = [
{name: "Peter", age: 35},
{name: "Emma", age: 21},
{name: "Jack", age: 53}
];
objs.sort(function(a, b) {
return a.age - b.age;
}); // Sort by age (lowest first)
string comparison in javascript
console.log("10" == "10"); //True
console.log(parseInt(10) == 10); // True Best practice
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us