There are several ways to create a string. The simplest is to enclose a set of characters in quotes, which can be assigned to a string variable.
var myStr = "Hello, String!";
You can use double quotes or single quotes to enclose a string, but be aware that the pair of quotes that delimit the string must be the same and cannot be mixed.
A statement like var myString = "Fluffy is a pretty cat.'; is illegal.
Allows the use of two kinds of quotation marks, making certain operations simple, such as embedding one type into the other:
document.write("<img src='img/logo.jpg' height='30' width='100' alt="Logo">");
We created several strings in the above script, but in essence, they are not real string objects. To be precise, they are string type values. To create a string object, use the following statement: var strObj = new String("Hello, String!");
Use the typeof operator to check and you will find that the myStr type above is string, and the strObj type is object.
If you want to know the length of a string, use its length property: string.length.
How to get the character at the specified position of the string: string.charAt(index);