Friday 14 December 2012

Comments in JavaScript

In JavaScript comment can be done in two ways :-
1.  /* this is a comment */
2. // this is a comment

both are useful but it is a good practice if you use // rather than /* */ because there might be a possibility in your code that in between a comment there is '*/' which will terminate the comment at this place and rest of the comment will not be considered as a comment.

consider the following code:
/*
var rm_a = /a*/.match(s);
*/

here the comment will terminate after /a and it will result into an error.

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel