
Matthew P. answered 10/08/19
Software Engineer with BSE degree in Computer Science
There are a couple of reasons you might choose one over the other.
If you have a single character or a short string, you may opt for single quotations. This is purely stylistic and helps prevent the code from becoming visually "noisy" or cluttered. Often, programmers may be inconsistent about this. For example:
This next reason is more pragmatic. It's called nesting: if you need to have a full/double quotation mark inside a string, or a single quotation mark inside a string, and you want to avoid having to use escape characters to do it. For example, these two strings are equivalent:
Similarly, these two strings are also equivalent:
The second version of each pair is easier to write and read in the code editor, and eliminating the escape characters reduces the number of opportunities you have to make a mistake.