34,333
edits
Changes
→Single Line Comments
var myString = "Welcome to Technotopia"; // Variable containing welcome string
</pre>
In the above example everything after the // marker is considered a comment and, therefore, ignored by the JavaScript interpreter. This is provides an ideal method for palcing comments on the same line of script that descript what that particular script line does.
== Multi-line Comments ==
For the purposes of supporting comments that extend over multiple lines JavaScript borrowed some syntac from the C programming language. The start and end of lines of comments are marked by the /* and */ markers respectively. Everything immediately after the /* and befre the */ is considered to be a comment, regardless of where the markers appear on a line. For example:
<pre>
/*
This Function adds two numbers together
and returns the result of the addition
*/
function (num1, num2)
{
return (num1 + num2)
}
</pre>