Today I Learned

hashrocket A Hashrocket project

JavaScript Casing

The ES5 spec defined two methods for changing the case of a string, .toUpperCase() and .toLowerCase(). They work just like Ruby's upcase and downcase.

'test'.toUpperCase()
=> "TEST"
'TEST'.toLowerCase()
=> "test"

There are two similar methods called .toLocaleUpperCase() and .toLocaleLowerCase() which are intended to yield the correct result based on the host environment's locale. I have not seen these methods in the wild but I'm curious if they are used.

See More #javascript TILs
Looking for help? At Hashrocket, our JavaScript experts launch scalable, performant apps on the Web, Android and iOS. Contact us and find out how we can help you.