A string is a text inside the quotes which can be either single or double quotes.
- var string1 = "Double Quoted String";
- var string2 = 'Single Quoted String';
Concatenating the Strings : This can be achieved in javascript by using + operator or using concat() method.
Example using + operator:-
- var string1 = "Hello and Welcome";
- var string2 = "to the Strings in JavaScript";
- var result = string1 + " " + string2;
- alert(result);
- var string1 = "Hello and Welcome";
- var string2 = "to the Strings in JavaScript";
- var result = string1.concat(" ", string2);
- alert(result);
Using Single Quotes inside a String:-
Way 1 : If you are using double quotes for string so, use single quotes inside the string wherever needed.
- var str = "Hello and Welcome to the 'Strings' in JavaScript";
- alert(str);
- var str = 'Hello and Welcome to the \'Strings\' in JavaScript';
- alert(str);
Output of both of the above codes : Hello and Welcome to the 'Strings' in JavaScript
Converting the Case of a String Value
Converting to Uppercase - This can be achieved by using toUpperCase() Function of JavaScript

Join the conversation! Your thoughts help the community grow.