What is the difference between double quotes and single quotes in Javascript?


In PHP, there is a difference between using single and double quotes. In this case, single quotes are for "common strings ", and double quotes are used when you want to process the string (concatenate, for example).

Is there any difference between using ' and ' for strings in Javascript? Are there any performance changes, or conflicts with use strict , for example?


alert('foo'); // Aspas simples
alert("bar"); // Aspas duplas


There are no differences from a programming point of view, even using Strict Mode ( "use strict;" )

As pointed out by Carlos André, one approach is you can put single quotes inside the string or the opposite:

alert('Ola "Mundo"');
alert("Ola 'Mundo'");

However, if you are using JSON, strings in JSON use double quotes. Of course, several libraries also support single quotes, but using single quotes for strings does not conform to JSON standards .

Scroll to Top