Comments in JavaScript
Comments are lines in your code that JavaScript ignores when running the program. They are used to explain what the code does, making it easier to understand later – for yourself or for others reading your code.
Good comments improve code readability and help with debugging and collaboration.
Single-Line Comments
Use // for comments on a single line. Everything after // on that line is ignored.
Multi-Line (Block) Comments
Use /* to start and */ to end a comment that can span multiple lines.
When to Use Comments
- Explain complex logic.
- Document functions or variables.
- Temporarily disable code during testing (comment out lines).
- Add notes for future improvements.
Avoid over-commenting obvious code – write clear code instead.
Practical Example
Quick Quiz
Wir haben die Materialien überprüft, dennoch können Fehler vorkommen. Der Inhalt dient ausschließlich Bildungszwecken, daher verwende ihn auf eigene Verantwortung und überprüfe ihn bei Bedarf mit anderen Quellen.
✨ Frag Lara — deine KI-Lernpartnerin
Entsperre personalisierte Lernunterstützung. Lara kann Lektionen erklären, Themen zusammenfassen und deine Lernfragen beantworten — verfügbar ab dem Go-Tarif.
Lara hilft dir, schneller zu lernen — exklusiv für ReadyTools Go-, Plus- und Max-Mitglieder.

