Difference between " and '

J

jodleren

Hi

I have used JS for years, still I dont know this. I know the
difference in php but not in js.

window.open('page.htm'); and window.open("page.htm"); - what is the
difference?

/S
 
M

Marcio Faustino

Hi

I have used JS for years, still I dont know this. I know the
difference in php but not in js.

window.open('page.htm'); and window.open("page.htm"); - what is the
difference?

/S

None :)
In JavaScript it doesn't matter whether you use single or double
quotes.
 
P

Peter Michaux

Hi

I have used JS for years, still I dont know this. I know the
difference in php but not in js.

window.open('page.htm'); and window.open("page.htm"); - what is the
difference?

There is no real difference but using single quotation marks is a bit
more convenient when writing an HTML string. Single quotation marks
save needing to escape attribute double quotation marks.

'<div id="myDiv">asdf</div>'

vs.

"<div id=\"myDiv\">asdf</div>"

Peter
 
E

Evertjan.

Peter Michaux wrote on 28 dec 2007 in comp.lang.javascript:
There is no real difference but using single quotation marks is a bit
more convenient when writing an HTML string.

Not at all!
Single quotation marks
save needing to escape attribute double quotation marks.

'<div id="myDiv">asdf</div>'

vs.

"<div id=\"myDiv\">asdf</div>"

Eh? try:

'<div id="myDiv">asdf</div>'

vs.

"<div id='myDiv'>asdf</div>"
 
T

Thomas 'PointedEars' Lahn

Peter said:
There is no real difference but using single quotation marks is a bit
more convenient when writing an HTML string. Single quotation marks
save needing to escape attribute double quotation marks.

'<div id="myDiv">asdf</div>'

vs.

"<div id=\"myDiv\">asdf</div>"

vs.

"<div id='myDiv'>asdf</div>"

:)


PointedEars
 
D

Dr J R Stockton

In comp.lang.javascript message <9a809e27-5273-48d4-8623-c55b0708c4f0@e2
3g2000prf.googlegroups.com>, Fri, 28 Dec 2007 09:26:49, Peter Michaux
There is no real difference but using single quotation marks is a bit
more convenient when writing an HTML string.

IMHO, with a UK keyboard and my eyes, ' is better for writing a string
but " is better for reading one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top