Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: should i use ' or " char to define string? [duplicate]

Tags:

javascript

Possible Duplicate:
What is the difference between ‘ and “ in JavaScript?

Should i use ' or " char, to define a string in javascript?

Is it just a developer's choice? I think, strings more offten contains ' char, so i prefer using of "(with inner " translated to \").

What do you think?

like image 736
Feryt Avatar asked Nov 23 '25 21:11

Feryt


2 Answers

I prefer to use ", so after a full day of coding in JavaScript, I don't try to use ' on strings in C#

like image 159
Allen Rice Avatar answered Nov 25 '25 09:11

Allen Rice


Most of the time I use html elements like that :

<input type="button" onclick="alert('test')" />

because of the attribute value has double quotes, I use single quote to represent javascript strings.

like image 21
Canavar Avatar answered Nov 25 '25 10:11

Canavar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!