首页 > 其他 > 详细

单引号还是双引号

时间:2016-12-19 14:33:44      阅读:190      评论:0      收藏:0      [点我收藏+]
console.log("double"); vs console.log(‘single‘);

不应该以编码风格为重点,
而应该以引号内的内容为重点,
比如以下
alert(‘Say "Hello"‘);
alert("Say ‘Hello‘");

更复杂的
alert("It‘s \"game\" time.");
alert(‘It\‘s "game" time.‘);

ES6更喜欢用反斜杠

alert(`Use "double" and ‘single‘ quotes in the same string`);
alert(`The escape the \` back-tick character in a string`);

比如
`\`` === "`" // --> true
console.log("string text line 1\n"+
"string text line 2");
// "string text line 1
// string text line 2"

 

单引号还是双引号

原文:http://www.cnblogs.com/funnyweb/p/6197089.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!