Loading Please Wait...
JavaScript strings are for storing and manipulating text.
A JavaScript string is zero or more characters written inside quotes (single or double). You can even use quotes inside string if they do not match the enclosing quotes.
let text1 = "Lynxsia IT Solutions";
let text2 = 'Lynxsia IT Solutions';
let text3 = "'Lynxsia' IT Solutions";
let text4 = '"Lynxsia" IT Solutions';
As JavaScript uses quotes to write strings, any apostrophe, slashes, etc will mislead the JavaScript engine to chop (cut) the string and generate errors.
let text1 = "We are the "Lynxsia" IT Solutions"; // error
let text2 = 'It's a good day'; // error
Code | Result | Description |
---|---|---|
\' | ' | Single Quotes |
\" | " | Double Quotes |
\\ | \ | Backslash |
\b | Backspace | |
\f | Form Feed | |
\n | New Line | |
\r | Carriage Return | |
\t | Horizontal Tabulator | |
\v | Vertical Tabulator |
let text1 = "We are the \"Lynxsia\" IT Solutions";
let text2 = 'It\'s a good day';
For best readability, programmers often like to avoid code lines longer than 80 characters.
If a JavaScript statement does not fit on one line, the best place to break it is after an operator.
You can also break up a code line within a text string with a single backslash. The \ method is not the preferred method. It might not have universal support. Some browsers do not allow spaces behind the \ character.
A safer way to break up a string, is to use string addition
// after operator
let text1 =
"We are the Lynxsia IT Solutions";
// using backslash
let text2 = "We are the \
Lynxsia IT Solutions";
// using string addition
let text3 = "We are the " +
"Lynxsia IT Solutions";
Strings can also be defined as objects with the keyword
let a = new String("Lynxsia");
let a = "Lynxsia";
let b = new String("Lynxsia");
let c = new String("Lynxsia");
(a == b) // returns true
(a === b) // returns false
(b == c) // returns false
(b === c) // returns false
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved