JavaScript compares strings by their Unicode character codes rather than by visual alphabetical order, meaning uppercase letters (A-Z: 65-90) have lower character codes than lowercase letters (a-z: 97-122), so 'Z' < 'a' evaluates to true, and string numbers are compared by their character codes (e.g., '4' < '5' is true because 52 < 53).
Approfondir
Prérequis
- Pas de données disponibles.
Prochaines étapes
- Pas de données disponibles.
Approfondir
Comparing Strings in JavaScriptAjouté :
Can you guess all three outputs?
Comment your answer below, and the correct one is C. You should know that.
JavaScript doesn't compare letters the way we do. It compares their character codes under the hood. Char code of uppercase A is 65, and uppercase Z is 90. It gives false. Then, the lowercase A is 97. So, this line returns true.
Third line, is 4 greater than 5? This one looks simple, but remember, these are strings, not numbers. JavaScript again compares the character codes of 4 and 5, which are 52 and 53. So, string 4 is less than string 5, and the answer is false. So, the rule is simple.
JavaScript compares strings by their character codes, not by what they look like to us. If you want to master JavaScript concepts like this easily, my ebook is linked in bio.
Vidéos Similaires
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 views•2026-06-01











