Skip to content

Latest commit

 

History

History
89 lines (75 loc) · 2.8 KB

File metadata and controls

89 lines (75 loc) · 2.8 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
Comment Statements (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
Comment_JavaScript
JavaScript
TypeScript
DHTML
comments, ignoring
comment statements
b604824f-ac17-49d3-bcdb-2a893ab5fff8
13
mikejo5000
mikejo
ghogen

Comment Statements (JavaScript)

Causes comments to be ignored by the [!INCLUDEjavascript] parser.

Syntax

Single-line Comment:  
// comment   
Multiline Comment:  
/*  
comment  
*/  
Comments with conditional compilation:  
//@CondStatement   
  
/*@  
condStatement  
@*/  

Remarks

The comment argument is the text of any comment you want to include in your script. The condStatement argument is to be used if conditional compilation is activated. If single-line comments are used, there can be no space between the "//" and "@" characters.

Use comments to keep parts of a script from being read by the [!INCLUDEjavascript] parser. You can use comments to include explanatory remarks in a program.

If single-line comments are used, the parser ignores any text between the comment marker and the end of the line. If multi-line comments are used, the parser ignores any text between the beginning and end markers.

Comments are used to support conditional compilation while retaining compatibility with browsers that do not support that feature. These browsers treat those forms of comments as single-line or multi-line comments respectively.

Example

The following example illustrates the most common uses of comments.

/* This is a multiline comment that  
    can span as many lines as necessary.  */  
function myfunction(arg1, arg2){  
    var r;  
    // This is a single line comment.  
    r = arg1 + arg2  
    return(r);  
}  

Example

The following example shows how to use conditional compilation. This example uses special comment delimiters that are used only if conditional compilation is activated by the @cc_on statement. Scripting engines that do not support conditional compilation see only the message that says conditional compilation is not supported.

/*@cc_on @*/  
/*@if (@_jscript_version >= 4)  
    alert("JavaScript version 4 or better");  
    @else @*/  
    alert("Conditional compilation not supported by this scripting engine.");  
/*@end @*/  

Requirements

[!INCLUDEjsv1]