Zen*_*rus 19 javascript jslint use-strict
我想知道,因为我试图用use strict,它的问题,如果我一起去"use strict"还是'use strict'?
这些都是"更正确"的选择吗?
Vit*_*ova 19
实际上在Javascript中使用双引号或单引号不会改变任何东西.
在整个代码中使用相同的选项更为重要.
即使你使用混合引号也不会改变任何东西:
'use strict'
var myString = "double quotes string"
Run Code Online (Sandbox Code Playgroud)
因此,使用use strict双引号或单引号是相同的.
在许多库中,它们通常使用其中一个用于字符串,另一个用于避免转义,如下例所示:
'A string that\'s single quoted'
"a string that's double quoted"
Run Code Online (Sandbox Code Playgroud)
因此,特别是在英语中,有时使用双引号而不是单引号来避免这种逃避的事情是有用的.