Comments in Java script
To create a single line comment in JavaScript, you place two
slashes "//" in front of the code or text you wish to have the JavaScript interpreter ignore. When you place these two slashes, all text to the right of them will be ignored, until the next line. Have you ever written a script or a program in the past only to look at it six months later with no idea what's going on in the code? You probably forgot to do what all programmers tend to forget to do: write comments! Advantages of JavaScript comments There are mainly two advantages of JavaScript comments. To make code easy to understand It can be used to elaborate the code so that end user can easily understand the code. To avoid the unnecessary code It can also be used to avoid the code being executed. Sometimes, we add the code to perform some action. But after sometime, there may be need to disable the code. In such case, it is better to use comments.
No comments:
Post a Comment