What symbol starts a single-line comment in JavaScript?

The story behind the answer

The symbol `//` starts a single-line comment in JavaScript. Everything after the two forward slashes, up to the line terminator, is treated as a comment rather than executable code.

JavaScript also supports block comments, written between `/*` and `*/`. Block comments may span several lines, while `//` comments end automatically at the next line break. Both forms are ignored during execution, although comments remain useful to developers and documentation tools.

The syntax comes from the C family of programming languages and is shared by languages such as C++, Java, and C#. A common mix-up is confusing JavaScript's `//` with Python's `#`; JavaScript also supports a special Unix-style hashbang beginning with `#!` at the start of an executable script, but that is not the ordinary comment marker.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: