String Comparison in Javascript 🔥

Published: 12 March 2024
on channel: RoadsideCoder
6,281
305

In JavaScript, you can compare strings using comparison operators

const str1 = "apple";
const str2 = "banana";

// Using comparison operators
console.log(str1 === str2); // Output: false

// You can use localeCompare method for string comparison
console.log(str1.localeCompare(str2)); // Output: -1 (indicates str1 comes before str2 in dictionary order)


On this page of the site you can watch the video online String Comparison in Javascript 🔥 with a duration of hours minute second in good quality, which was uploaded by the user RoadsideCoder 12 March 2024, share the link with friends and acquaintances, this video has already been watched 6,281 times on youtube and it was liked by 305 viewers. Enjoy your viewing!