I would like to understand the logic behind that code:
var myName = "John";
document.write("\""+ myName +"\"");
I got what I wanted, ie broswer displayed "John" with double quotes around, but I don't uderstand why I had to use + before and after the string and why escape seq. had to be used in such manner.
'"' + myName + '"'. use single quotes around the double quote, so you don't have to escape the middle double quotedocument.write, stop now. It will undoubtedly be woefully outdated: the uses fordocument.writeare almost nil in 2017.document.writeis three characters longer thanconsole.log, so you're actually costing yourself effort. (And it's not as good -- it's only useful for numbers and strings.)