What is the toLowercase() method of a string in TypeScript?

Overview

We can get the lowercase representation of a string in TypeScript by using the toLowerCase() method. This method is available in JavaScript as well.

Note: This method does not permanently modify the string.

Syntax

string.toLowerCase()
Syntax for leftTrim() method in TypeScript

Parameters

string: This is the string we want to convert to uppercase.

Return value

This method returns the lowercase equivalent of the string string.

Example

export {}
// create some strings.
let name:string = "TheoDORE"
let role:string = "SOFTWARE DEVELOPER"
let nickName:string = "KCEE"
let hubby:string = "CoDIng"
// convert to uppercase
console.log(name.toLowerCase())
console.log(role.toLowerCase())
console.log(nickName.toLowerCase())
console.log(hubby.toLowerCase())

Explanation

  • Line 1: We export our file as a module.
  • Lines 4–7: We create some strings.
  • Lines 10–13: We use the tolowerCase() method to get the uppercase versions of our strings and print them to the console.

Free Resources