Thursday, April 4, 2013

jquery and javascript syntax - double quote or single quote?

I have always wonder which was a better choice for when writing string type codes.  For example, $("hi") or $('hi)

Answer:  It doesn't matter.  However if you have a string statement that contains quotes you would need to use both single and double to contain the string.  Using this method you would not need to use special codes for those symbols.

eg,
error

'today's special'

no error

"today's special"
'she said "boom"'

No comments:

Post a Comment