While working with client scripting every now and
then one may face challenge to add inverted commas or quotes in strings.
We can add
inverted commas or quotes proceeding by a backslash character. This allows the
JavaScript interpreter to differentiate a quote within the string from the
quotes that serve as string delimiters.
Let’s see
an example:
testString1 = 'It\'s one o\'clock!';
testString2
= "<a
href=\"testpage.html\">";
|
Alternatively,
if string includes single quotes only, then you can use double quotes as string
delimiters, and vice versa, as mentioned in below example.
testString1 ="It's one o'clock!";
testString2
='<a
href="testpage.html">’;
|
Comments
Post a Comment