String
Introduction
String is a Data Type that is used to store storing and manipulating text.
Strings are written inside Double Quotes or Single Quotes.
Example :
"hello" , "Hey There" , "Any Text" , "123", "World123"
Any Thing you write inside Double Quotes is considered to be a Text by Javascript.
Declaring String
Syntax
You can use Double Quotes or Single Quotes, Both Will Work.
Example
Escape Character
As you all know, Strings are written inside the Double quotes or Single Quotes. So, when you will try to enter a word inside double quotes then javascript will misunderstand it and thus will not give desired output
For Example :
Correct Program
To Achieve Desired Output You have to use Backslash (\\)
Here We have list of Escape Characters. These are also used for Giving Special Functionality Like New Line or Vertical Space.
Escape Characters
String Methods
We have some Predefined Function To Perform Specific Task on String Like Converting it to Upper Case Text or Cropping some Part of The String.
Let's See them in details
We have considered str is a variable containing String.