js中字符串使用单引号还是双引号

ES6如下描述:

字符串

静态字符串一律使用单引号或反引号,不使用双引号。动态字符串使用反引号。

// bad
const a = "foobar";
const b = 'foo' + a + 'bar';

// acceptable
const c = `foobar`;

// good
const a = 'foobar';
const b = `foo${a}bar`;
posted @ 2023-10-31 18:07  SimoonJia  阅读(269)  评论(0)    收藏  举报