JavaScript: String.prototype.toLowerCase

By Xah Lee. Date: . Last updated: .

toUpperCase

str.toUpperCase()
Return a string of upper case version of string str.

works on Greek or any unicode that has upper/lower case defined.

console.log( "abc".toUpperCase() === "ABC" ); // true
console.log( "δγπ".toUpperCase() === "ΔΓΠ" ); // true

toLowerCase

str.toLowerCase()
Return a string of lower case version of string str.
console.log( "ABC".toLowerCase() === "abc" ); // true
console.log( "ΔΓΠ".toLowerCase() === "δγπ" ); // true

toLocaleUpperCase, toLocaleLowerCase

str.toLocaleUpperCase()
same as str.toUpperCase(), except that it may be different in some languages (for example, Turkish). JavaScript implementation may not chose to have this behavior. In that case, its identical to str.toUpperCase().

Here's quote from spec:

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the toLocaleUpperCase method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleUpperCase method is used.

This function interprets a String value as a sequence of UTF-16 encoded code points, as described in 6.1.4.

This function works exactly the same as toUpperCase except that its result is intended to yield the correct result for the host environment’s current locale, rather than a locale-independent result. There will only be a difference in the few cases (such as Turkish) where the rules for that language conflict with the regular Unicode case mappings.

ECMAScript 2015 §Text Processing#sec-string.prototype.tolocalelowercase

JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

String

prototype