I came across an interesting article. Which states unless until we are defining JSON we should use only single quote.
var foo = 'bar'; //Right way
var foo = "bar"; //Wrong way
Can anyone put light on this, why is it so?
Any help greatly appreciated.
The most likely reason is programmer preference / API consistency.
Strictly speaking, there is no difference in meaning; so the choice comes down to convenience.
Here are several factors that could influence your choise:
'Joe\'s got a cool bike.'
) When using double quotes, they don't. ("Joe's got a cool bike."
) Apostrophes are much more common in English strings than double quotes.Please check following post that might be helpful for you When to Use Double or Single Quotes in JavaScript