re: What is the difference between using ` and "/' for strings in JavaScript? VIEW POST

re: Hey, question... Why are there so many kinds of strings in each language, and why?

There are three reasons why Ruby has two types of strings.

  1. Double quote " requires two bytes, while single quote ' requires only 1 byte. The more compelling reasons are

  2. If you want to create a string that has an apostrophe in it, for example She's writing code, with a single quote it would break the string. So the two ways to write it are "She's writing code" or with escaping 'She\'s writing code' which is just harder to read.

  3. As others mentioned, Ruby has interpolation (a feature Javascript did not have till more recently) so

passion = "writing code"
"She's #{passion}" 

Also works.

code of conduct - report abuse