23

I was wondering since I'm trying to use use strict, does it matter if I go with "use strict" or 'use strict'?

Is any of those a «more correct» option?

Vikrant
  • 4,920
  • 17
  • 48
  • 72
Zentaurus
  • 758
  • 2
  • 11
  • 27
  • 9
    no. [To invoke strict mode for an entire script, put the exact statement "use strict"; (or 'use strict';) before any other statements.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode) – georg Dec 30 '13 at 14:26
  • 4
    Just stick with the same quotation style you use in the rest of your code. All of your code should look like it was written by one person. – sbking Dec 30 '13 at 14:36
  • 1
    See also the ES5 spec on Use Strict Directives (which says the same things as the MDN page, above): http://www.ecma-international.org/ecma-262/5.1/#sec-14.1 – apsillers Dec 30 '13 at 14:37

2 Answers2

23

Actually in Javascript using double quotes or single quotes doesn't change anything.

It's more important you use the same option in your entire code.

Even if you use mixed quotes it will not change anything:

'use strict'
var myString = "double quotes string"

So using use strict with double quotes or single quotes are the same.

In many libraries they commonly use one of them for strings and another to avoid escape, like in this example:

'A string that\'s single quoted'

"a string that's double quoted"

So specifically in English sometimes is useful using double quotes instead of single quotes to avoid this kind of escape thing.

Vitor Canova
  • 3,918
  • 5
  • 31
  • 55
-4

No, in pretty much any code language, it does not matter whatsoever what type of quotes you use.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
  • 2
    Actually, in a number of languages - Perl and PHP come to mind - single and double quotes have different behaviors. See for example [What is the difference between single-quoted and double-quoted strings in PHP?](http://stackoverflow.com/q/3446216) – Paul Roub Jun 04 '17 at 21:28
  • @PaulRoub Yes, there is a small difference depending on what language your currently using, but that doesn't mean that they can't experiment and figure out what's right or wrong. A waste of a post if you ask me. – Will Hoffman Jun 04 '17 at 21:48