r/learnjavascript • u/grave4us • Apr 11 '26
Has anyone actually used string comparison? Tell me where might that come in handy?
like alert(“Y” > “A”); //true
0
Upvotes
r/learnjavascript • u/grave4us • Apr 11 '26
like alert(“Y” > “A”); //true
View all comments
Show parent comment
2
u/dymos helpful Apr 11 '26
There's a kind of tangential relationship here in that strings are a list of characters. I think I agree though that trying to teach string manipulation methods in a tutorial sounds a bit too trivial unless it happens to be building up to something that's part of the tutorial, a purpose.
Probably also depending on when you learnt (or when the tutorial was written), the websites with good tutorials were almost a quasi-documentation provider. I think now that we have much better official documentation for many languages, those are a much better place to learn about specific trivialities like string manipulation methods.
For example let's for arguments sake say that I needed a list of strings to be the same length and if they aren't long enough I need to prefix them with a placeholder. Googling that 15 years ago would have probably resulted in a tutorial somewhere or a stack overflow post giving a custom method. Now the link to MDN's page for padLeft would probably be near the top.
That's a fair take, string comparison can be useful for sorting, but indeed you need to be aware of how/why that works so you can understand how to get the right result.