2914Re: Mixed single and double quotes
- Jul 2, 2012
> You should be glad to know that what you find annoying is not a consideration. I am concerned instead with correctness and readability.Mixing of quotes can be a maintainability issue. In my own application I have all of my logic divided into libraries that are directly supplied to a parent container function representing the entirety of the application. Many of these library components I have forked from other authors. Some have used single quotes and other used double quotes. If the logic in each library never moves out of the library you are fine, but if you want to transplant one condition to another library item you could run into trouble.
With regards to Hawkinson's comment about nested quotes I come up with a tedious solution in my own app. I have chosen to use double quotes for everything where a quote is required in the JS syntax. If there exists a string already containing a double quote character as part of the string literal I escape it instead of shying away from consistency.
var example = "what I am doing with \" characters";
As long as you are using an editor that performs syntax coloring there is no harm to readability. Otherwise you actually have to read that there is a forward slash before the quote character and the string continues. I have not found this to be a problem
- << Previous post in topic Next post in topic >>