Some important and most usable operations on string.
Nov 4, 2020
In this articale we will know about Some important and most usable operations on string.
toUpperCase:
By this operation you can make your values to uppercase though you write your values in lowercase.
Example:
let name = “Nayemul Alam” ;console.log(“My name is” + name.toUpperCase()); //output:_ My name is NAYEMUL ALAM //
toLowerCase:
This operation works the opposite of toUpperCase .
Example:
let name = “Nayemul Alam” ;console.log(“My name is” + name.toLowerCase()); //output:_ My name is nayemul alam //
slice():
This slice() method extracts a section of a string and returns it as a new string, without modifying the original string.
Example:
let line = “My name is Nayemul Alam”;console.log(line.slice(11, 23)); //output:_ Nayemul Alam //
trim():
The trim() method removes whitespace from both ends of a string.
Example:
let name = “ Nayemul Alam ” ;console.log(“My name is” + name.toLowerCase()); //output:_ My name isNayemul Alam//