1. Home
  2. Computer Science MCQs
  3. Javascript
  4. How can you comment a single line of code in JavaScript?

Added 28 Jan 2024

How can you comment a single line of code in JavaScript?

  1. <!-- This is a comment -->
  2. // This is a comment Correct answer
  3. /* This is a comment */
  4. ** This is a comment **

Correct answer

B. // This is a comment

15 views

MCQSEXAM

Explanation

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.

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Javascript MCQs

Practise all Javascript MCQs

Similar MCQs