JS: 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 RegExp

  1. RegExp Tutorial
  2. RegExp Syntax
  3. Regex Find/Replace

JS String

  1. String Overview
  2. Template String
  3. Char, Code Unit, Codepoint
  4. String Escape Sequence
  5. Unicode Escape Sequence

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. CSS
  3. JavaScript
  4. JS Obj Ref
  5. DOM
  6. SVG
  7. Blog