Using Comments in JavaScript

Due to their shared inheritance from the C programming language, PHP and JavaScript share many similarities, one of which is commenting. First there’s the single line comment, like this:

// This is a comment

This style uses a pair of forward slash characters (//) to inform JavaScript that everything following is to be ignored. And then you also have multiline comments, like this:

/* This is a section
of multiline comments
that will not be
interpreted */

Here you start a multiline comment with the sequence /* and end it with */. Just remember that you cannot nest multiline comments, so make sure that you don’t comment out large sections of code that already contain multiline comments.


You may also like...