We have a few objectives here:
Introduce the String Concatenation. Work with String Escape character and string length property Give Overview about the Boolean, null and undefined type.
String Character) and you can also write all three style of string in the same script file too.
Here is an example of string below where we have used all three styles of string.
If we start writing with double quotation but end it with single or Backticks Quotation, then there is an error.
Because quotes need to match.
Concatenation: So one of the things that we can do with strings is added them together just like numbers.
Like we can add “string” + “string”.
It is called Concatenation.
Here is an example of concatenation below:
Let’s see what happens if we add space after “Hey ” string.
You can notice space between ‘Hey’ and ‘geeks’ in above output screenshot, so this is how we can use space between texts in string concatenation.
Every string we create has a length property.
Length property refers to the number of characters in the string.
So if I create a string “Geeks” and add .length with it, it tells me that it is 5 characters long.
It includes each and every character like words, numbers, symbols, and spacing as well.
Access individual character by using [ ]
We can also retrieve the entire length of a string using length property and we can also retrieve individual characters like the 4th character or 7th character by using this “square bracket [ ]” notation.
This function mainly used with variables.
It works when we put [ ] and gives a number to it, that number will correspond with the position with the string of that character we want.
We have also discussed single, double and Backticks quotation in the string and given the detailed overview regarding concatenation, escaping, and how anyone can access individual character using length property.