Loading

Quipoin Menu

Learn • Practice • Grow

java-script / Comments in JS
interview

Q1. What Are the Types of Comments in JavaScript?
JavaScript supports two types of comments:

1. Single Line Comment
Used for writing a cooment in one line.

// This is a single-line comment


2. Multi Line Comment
Used for writin comments across multiple lines.

/*
This is a
multi-line comment
*/


Q2. Why Are Comments Important in JavaScript?
Comments are important because they:
  • Improve code readability
  • Help explain complex logic
  • Make debugging easier
  • Help team members understand code
  • Provide documentation for future reference


Q3. Can Comments Affect Program Performance?
No, comments do not affect performance because they are ignored during code execution.
They are only useful for developers and do not run inside the program.


Q4. What Are Best Practices for Writing Comments?
  • Keep comments clear and meaningful
  • Avoid unnecessary comments
  • Explain why code is written, not just what it does
  • Keep comments updated with code changes
  • Use comments to describe complex logic