In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what is the difference between single quotation marks and double quotation marks in javascript". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
Operating environment of this tutorial: Windows 7 system, Javascript version 1.8.5, Dell G3 computer.
There is no difference between single quotes and double quotes in JavaScript, see if you are used to it.
/* Initialize the string with single quotes and double quotes */var str1='I love JavaScript';var str1='I love JavaScript';docunment.write(str1+'
');docunment.write(str2+'
');
The results were as follows:
I love JavaScriptI love JavaScript
However, if we use quotation marks again, we can adopt the format of "outer double inside single" or "outer single inside double"; if we want the double quotation mark itself, we can only use "outer single inside double":
Example: Initialize a string with a mixture of single and double quotes
var str1 = 'I love "JavaScript"';var str2 = "I love 'JavaScript'";[xss_clean](str1);[xss_clean](str2);
The results were as follows:
I love "JavaScript"I love 'JavaScript'
Example: All single quotes or all double quotes
var str1 = 'I love 'JavaScript'';var str2 = "I love "JavaScript"";[xss_clean](str1);[xss_clean](str2);
As a result, the program directly went wrong!
Example: Transfer with backslash
var str1 = 'I love \'JavaScript\'';var str2 = "I love \"JavaScript\"";[xss_clean](str1);[xss_clean](str2);
The results were as follows:
I love 'JavaScript'I love "JavaScript"
So the fool thinks the conclusion is as follows
Conclusion:
(1) Character strings that use only characters, there is no difference between single quotes and double quotes
(2) Double quotation marks can be used directly in strings included in single quotation marks, and single quotation marks can be used directly in strings included in double quotation marks.
(3) If double quotation marks are used in the string included in double quotation marks, backslashes are needed to escape, note "\" ; similarly, single quotation marks are used in the string included in single quotation marks, and escape "\" is also needed.
"javascript single quotation marks and double quotation marks what is the difference" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.