Single quotes and double quotes are usually related to whether a string replacement will occur, but in JS it does not matter as far as I know.
the difference between 3 is that the first one is the assignment of a variable where a line replacement can be performed. the second passes the string as an argument, and the third passes the variable or constant topic
var topicOne = "Community1"; function write(toOutput) { document.write(toOutput); } write(topicOne); write("topicOne"); write('topicOne');
so here comes 3:
Community1 topicOne topicOne
In PHP, however, the same code will act differently because a double quote means replacing a string
<?php $topicOne = "community1"; $topicTwo = "community2$topicOne"; function write($toOutput) { print $toOutput; } write($topicOne); write("$topicOne"); write('$topicOne'); write($topicTwo); write("$topicTwo"); write('$topicTwo'); ?>
will produce a different output
community1 community1 $topicOne community2community1 community2community1 $topicTwo
See where the difference is?
Michael
source share