473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Trivial Question About Quotes

When JavaScripting, I've often seen strings wrapped with single-
quotes:
----------------------------------------------------------------
var language = 'English';
----------------------------------------------------------------

However, I prefer double-quotes due to my experience with C++:
----------------------------------------------------------------
var language = "English";
----------------------------------------------------------------

Is there a problem with this? Why is everyone else, including those
who write popular libraries like Prototype.js, using single-quotes? I
know that it's best to stick to a single style when you code(that is,
if your coding style isn't horrible), but is using double-quotes
horrible? Or is it just because you want to use double-quotes inside
strings? :
----------------------------------------------------------------
var example = 'She says, "Hello, world!"';
----------------------------------------------------------------

I know this is a trivial question, but please give me as much
details as possible...^^;;
Jun 27 '08 #1
1 938
* philmasterplus wrote in comp.lang.javascript:
When JavaScripting, I've often seen strings wrapped with single-
quotes:
----------------------------------------------------------------
var language = 'English';
----------------------------------------------------------------

However, I prefer double-quotes due to my experience with C++:
----------------------------------------------------------------
var language = "English";
----------------------------------------------------------------

Is there a problem with this? Why is everyone else, including those
who write popular libraries like Prototype.js, using single-quotes?
There can be a variety of reasons. For example, on some keyboards the
apostrophe is easier to enter (e.g., you might not have to press shift);
in some programming languages variables and most escaped sequences are
interpolated and recognized in "-literals but not in '-literals; quot is
easily confused with two apos characters in some environments; some may
have a convention like `" for markup attributes, ' for script code` so
they avoid misnesting them in onclick="...'...'..." attributes, or their
native language might be using some kind of single quote mark so they
are more used to them. And so on.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr...
6
by: Jimmy Clay | last post by:
I have a very basic question about how to include files to be used by another file. I'm trying to include a bad word filter into the guestmap on my website. I know almost nothing about PHP code....
7
by: Steven W. Orr | last post by:
Python has a number of "quoting" 'options' to help """with times when""" one way may be more convenient than another. In the world of shell scripting, I use a technique that I call minimal...
2
by: jamesgoode | last post by:
Hi, I'm trying to write fast code, and I'm wondering which is faster, generating strings with double quotes or single quotes - aka, $string = "My name is $name"; or $string = 'My name is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.