JavaScript
Article

How to Comment in jQuery

By Sam Deering

How to use comments in jQuery, automate your comments using a plugin and effectively comment witout floading comments use them effectively.

Basic jQuery comments

jQuery comments are started with a double forward slash which tells the interpreter that the following text on the line is not to be processed as JavaScript. jQuery comments can be either inside a function or outside it makes no difference.

function myFunction ( myVar, myVar2 ) {
// Pay attention to spaces around
// the brackets and curly brackets
}
// some prefere it like this
function myFunction()
{
...
}

Multi-line jQuery comments

Multi-line jQuery comments are enclosed within a combination of a forward slash and an asterisk like so:

/* comment */

jQuery Commenting Guidelines

Here are a couple of pointers for commenting in jQuery:

  1. Long comments should use /* ... */.
  2. Single line comments should always be on their own line and be
    above the line they reference. Additionally there should be an
    extra endline above it. For example:

var some = "stuff";

   // We're going to loop here
   for ( var i = 0; i < 10; i++ ) {}
[/js]

Source: http://docs.jquery.com/JQuery_Core_Style_Guidelines

Free Guide:

7 Habits of Successful CTOs

"What makes a great CTO?" Engineering skills? Business savvy? An innate tendency to channel a mythical creature (ahem, unicorn)? All of the above? Discover the top traits of the most successful CTOs in this free guide.

  • rocker

    cool

  • http://bikeshgoja.com.np

    good

  • http://www.facebook.com/profile.php?id=100004658911479 Vijay Vijay

    test

  • hung

    xin chao ban

  • unknown

    test

    • http://netsca.pe/ LeoTM

      test

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.