Why single quotes?


Hello all,

Just wondering why in the switch lessons we are suddenly using single quotes for strings. I haven't found anything yet saying this is a best practice (though, in fact, some arguments to the contrary), but is that the case? Or perhaps just to show that it is an option? Or some other reason I am missing?

Thank you,


Replace this line with your code.


Just always use double quotes for strings.

Of course, this is no hard and fast rule, but it helps when you start writing code in other languages. For example, Java defines a string as characters enclosed in double quotes ", while a character as enclosed in single quotes '. Both are wildly different, and therefore, if you use ' for strings in js, you might also start writing strings in java with single quotes and that might hamper your initial progress. Moreover, when using JSON, strings must only be double quotes.

Of course, our brain has neuroplasiticity so you will adapt quickly and therefore this isn't much of a problem.

So, it's all about consistency and compatibility with standards.


Thank you for your help, @gaurangtandon! I will go with your advice.

I did read about the potential issues with Java and JSON yesterday but didn't know what chars or JSON were; after your reply I've done some reading; would it be correct to generalize java strings as arrays of java chars? I'm still having trouble understanding JSON but am hoping it will become clearer as I continue studying.

Would there be any cases where something in single quotes in JS would be something other than a string? Or are single and double-quoted words always strings (in JS)?

Thank you again,


Yes, you may only relate them in the manner that you can access individual characters of a string using indices just as you would access individual elements of an array. Apart from that, they are very different (at least in Java).

No, not at all.

Yes, they always are.


Thank you for your answers, @gaurangtandon. I appreciate you taking the time to explain everything to me regarding strings and chars in Java and JS! In case I study Java in the future, etc., I will continue to favor double quotes as suggested.