Comments in JavaScript

Like other programming languages, we can use Comments within our JavaScript code to for documentation or for easy understanding. Comments can be used before or after any line of code within the code.


Note that these comments are to be used within JavaScript codes only and should not be used outside the script area or in our html areas.


Single line comments we can place comment any where by adding // before the line. Here is an example.


<script type="text/javascript">
var msg="Welcome to plus2net";
document.write(msg);
// Display message through variable </script>
We can place comments at the end of a line also.

<script type="text/javascript">
var msg="Welcome to plus2net";
document.write(msg); // Display message
</script>

Multiline comments

Comments can be extended to multiline also. Like this .

<script type="text/javascript">
/*
The below line will display
Welcome message to all 
visitors of plus2net.com
*/
var msg="Welcome to plus2net";
document.write(msg); 
</script>


plus2net.com




Francis

08-04-2010

I really loved this website guys.

Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer