JS: String.prototype.toLowerCase

By Xah Lee. Date: .


s.toUpperCase() → return a string of upper case version of string s.

console.log ( "abc".toUpperCase() === "ABC" ); // true

// works on Greek or any unicode that has upper/lower case defined
console.log ( "αβχ".toUpperCase() === "ΑΒΧ" ); // true


s.toLowerCase() → return a string of lower case version of string s.

console.log ( "ABC".toLowerCase() === "abc" ); // true
console.log ( "ΑΒΧ".toLowerCase() === "αβχ" ); // true

toLocaleUpperCase, toLocaleLowerCase

s.toLocaleUpperCase() → same as s.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 s.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
  4. RegExp Object
  5. RegExp Constructor
  6. RegExp.prototype

JS String

  1. String Overview
  2. Template String
  3. Char, Code Unit, Codepoint
  4. String Escape Sequence
  5. Unicode Escape Sequence
Liket it? I spend 2 years writing this tutorial. Help me spread it. Tell 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. Visual CSS
  3. JS in Depth
  4. JS Object Reference
  5. DOM Scripting
  6. SVG
  7. Blog