Leaving comments in code

for JavaScript single line comments are // and double //* -why? why isn a comment indicator the same regardless of link as with HTML and CSS? are there other coding languages that do this? are there and coding languages which have really weird comment notations or difficult/nonsense?

If we only had // for comments then all comments would have to be on a single line and that would get messy real fast. Code formatting for easy readability is important, and the same goes for comments, so there is a need for multi-line comments and thus we have /* ... */ for those.

I suppose we could do away with // and just force all comments to use /* ... */ like CSS does. But you have to understand, programmers are lazy by nature. And that’s not a bad thing. Why spend the extra keystrokes having to type /* and */ for a single line comment when you can just type //? Single line comments are so common that you will save a lot of typing.

So really, I would ask why CSS forces you to always use /* ... */.

1 Like

perfect answer. thank you

1 Like