String in Javascript
JavaScript is now considered as the most popular software programming language in the world. When you programming with this language, you can understand that “Strings” are on of the most important component of JavaScript, probably used more than any other fundamental data types.
Javascript String stores a group of characters and are named similarly to other variables. You can create Javascript string in two ways.
string str = "This is a string";
String str = new String("This is a string");
A JavaScript string can be considered as both a primitive data type or an Object. Here the second method uses Object Oriented method to create a new string. Although you can create a new string using Object Oriented method, the standard JavaScript syntax for creating string is simpler, and there is any difference in the strings created by these two methods.
Javascript string is delimited by quotes, either single quotes or double quotes.
string str = 'this is a string';
string str = "this is a string";
If you try to mix up the quote types like begin a string with a double quote and end with a single quote or vice versa, your program end with an application error.
string str = "this is a string'; //wrong usage
One of the popular string methods that all JavaScript Objects implement is toString() method, which returns a string containing the serialized format of the Object. From the following lessons you can learn more about Javascript String operations and manipulations.