4 ms·
I'm not exactly sure why, but that seems to be the case. It might be due to the ubiquitous AirBnB JS Style guide (https://github.com/airbnb/javascript https://g
by 49531 11y ago
I'm not exactly sure why, but that seems to be the case. It might be due to the ubiquitous AirBnB JS Style guide (https://github.com/airbnb/javascript https://github.com/airbnb/javascript) which enforces single quotes. It's the style guide we use on my team.
- zeven7 11y agoSingle quotes have been mainstream in JS for much longer than AirBnB has been around. Take for example, the Google style guide[1]: > For consistency single-quotes (') are preferred to double-quotes ("). This is helpful when creating strings that include HTML Or take the oldest version of Prototype JS I could find (a JS library from the old days), version 1.5 from Jan 2007[2]. A simple search of the source shows 690 occurrences of ' and 48 occurrences of ". jQuery 1.0, dated 2006[3] is a counter example which has many more occurrences of double quotes, but I believe single quotes were generally more common even before that. I think, in addition to the HTML thing mentioned already, PHP also had a lot to do with it, since single quotes would be encouraged in PHP when you just want a plain string. [1] https://google.github.io/styleguide/javascriptguide.xml?showone=Strings#Strings https://google.github.io/styleguide/javascriptguide.xml?show... [2] http://prototypejs.org/assets/2007/1/18/prototype.js http://prototypejs.org/assets/2007/1/18/prototype.js [3] https://code.jquery.com/jquery-1.0.js https://code.jquery.com/jquery-1.0.js