Comments (7)
This a preference. The important thing, as @jaseemabid points out is consistency. At Airbnb we use ''
which is what is reflected in the style guide.
Feel free to fork the style guide and make one that prefers ""
over ''
for you and your team.
from javascript.
The eslint rule allows for double quotes when it would avoid escaping backslashes.
However, since both straight quotes are typographically incorrect - you should be using curly quotes in prose - this is only a problem when working with strings of html, which double-quotes itβs attributes. Thus, itβs basically never a problem with correct code/text.
from javascript.
@GurudayalKhalsa I would say pick any and be consistent.
Generally its a convention to use " in html and if you have inline html in your js (we all have some, don't we? ) its easier to quote it all with a single ', without a lot of \
from javascript.
@GurudayalKhalsa, single-quoted strings look better for me
- " === + '. Easier to type =)
- In PHP single-quoted strings are just plain strings, double-quoted strings allow to put variables inside and therefore work a bit slower. So it is just a habit to use single-quotes.
from javascript.
Just to add up, straight from coffeescript docs.
String Interpolation, Block Strings, and Block Comments
Ruby-style string interpolation is included in CoffeeScript. Double-quoted strings allow for interpolated values, using #{ ... }, and single-quoted strings are literal.
Single and double quoted strings behave exactly the same way in JS, but I got used to the coffee way and now its natural to write it that way..
from javascript.
One could use single-quote strings only if there are double quotes in the string, and use double-quote strings otherwise. It would still be consistent, though the rule maybe less obvious, and you lose an excuse for not double-quoting strings in many cases.
from javascript.
I just find that backticks are closer to single quotes than double quote and IMHO can sometime cause readability issues.
HTML fits (today) well in a backticks bloc as it allows for a clean multiline implementation without any collision with most common quote style (single and double).
from javascript.
Related Issues (20)
- [spam]
- [spam] HOT 1
- Multiline comments HOT 3
- [spam]
- [spam]
- TypeError: Failed to load plugin 'jsx-a11y' declared HOT 4
- [spam]
- [spam] HOT 1
- Regarding Updation HOT 4
- [spam] HOT 1
- [spam]
- Link 404 not found HOT 2
- Can we add on quiz sections on this repo too HOT 11
- [spam]
- eslint v9 support
- [spam]
- import/no-extraneous-dependencies shouldn't be a code style rule HOT 25
- Parsing error: Unexpected character '#' HOT 3
- [spam] HOT 1
- [spam]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javascript.