Use single or double quotation marks for strings in JavaScript? [duplicate]

3

Is there any difference between writing a literal string in single or double quotation marks?

Example:

var s = 'texto';
// ou
var s = "texto";
    
asked by anonymous 10.03.2017 / 15:28

1 answer

4
It's a matter of taste. They make no difference in JavaScript.

There may be cases where one is more practical, for example:

var stringA = 'Olá Mc\'Neil';
var stringB = "Olá Mc'Neil";

console.log(stringA, '|', stringB); // Olá Mc'Neil | Olá Mc'Neil

In other languages how PHP is different.

    
10.03.2017 / 15:30