Comments

JavaScript supports two styles of comments.

  1. Single-line comment - Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.
  2. Multi-line comment -  Any text between the characters /* and */ is also treated as a comment; these comments may span multiple lines but may not be nested.

 The following lines of code are all legal JavaScript comments:

// This is a single-line comment.
/* This is also a comment */ // And here is another.
/*
* This is yet another comment.
* It has multiple lines.
*/

 

  • Updated
    Aug 24, 2014
  • Views
    2,614