This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Johnny Simpson
a String
is a type of data in Javascript, and as with any other type of data, String
s have prototypes and therefore inherit standard methods. One of these methods is toLowerCase()
, which you'll often see written as String.prototype.toLowercase()
. This method turns any string from any case to just lowercase instead.
Here is a quick example:
let myString = 'HELLO WORLD'
console.log(myString.toLowerCase()) // hello world
This will work on anything which is of string type - so trying to initiate a new String()
and use this method also works:
let myString = new String('HELLO!')
console.log(myString.toLowerCase()) // hello!
This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Johnny Simpson
Johnny Simpson | Sciencx (2023-02-04T23:11:12+00:00) Javascript toLowerCase() – Convert Strings to Lowercase. Retrieved from https://www.scien.cx/2023/02/04/javascript-tolowercase-convert-strings-to-lowercase/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.