How can you comment a single line of code in JavaScript?
Correct answer
B. // This is a comment
15 views
B. // This is a comment
15 views
A single-line comment in JavaScript starts with // — everything after it on that line is ignored by the interpreter.
/* ... */ is also valid JavaScript but is the multi-line comment form, and <!-- --> is HTML comment syntax. Comments explain code to other developers and are handy for temporarily disabling a line while debugging.
Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.