<var> (JavaScript)
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
Specifies documentation information for a variable.
Syntax
<var type="ValueType" integer="true|false"
domElement="true|false" mayBeNull="true|false"
elementType="ArrayElementType" elementInteger="true|false"
elementDomElement="true|false" elementMayBeNull="true|false"
helpKeyword="keyword" locid="descriptionID">description
</var>
Parameters
type
Optional. The data type of the variable. The type can be one of the following:
An ECMAScript language type that's in the ECMAScript 5 specification, such as
Number
andObject
.A DOM object, such as
HTMLElement
,Window
, andDocument
.A JavaScript constructor function.
integer
Optional. Iftype
isNumber
, specifies whether the variable is an integer. Set totrue
to indicate that the variable is an integer; otherwise, set tofalse
. This attribute is not used by Visual Studio to provide IntelliSense information.domElement
Optional. This attribute is deprecated; thetype
attribute takes precedence over this attribute. This attribute specifies whether the documented variable is a DOM element. Set totrue
to specify that the variable is a DOM element; otherwise, set tofalse
. If thetype
attribute is not set anddomElement
is set totrue
, IntelliSense treats the documented variable as anHTMLElement
when performing statement completion.mayBeNull
Optional. Specifies whether the documented variable can be set to null. Set totrue
to indicate that the variable can be set to null; otherwise, set tofalse
. The default value isfalse
. This attribute is not used by Visual Studio to provide IntelliSense information.elementType
Optional. Iftype
isArray
, this attribute specifies the type of the elements in the array.elementInteger
Optional. Iftype
isArray
andelementType
isNumber
, this attribute specifies whether the elements in the array are integers. Set totrue
to indicate that the elements in the array are integers; otherwise, set tofalse
. This attribute is not used by Visual Studio to provide IntelliSense information.elementDomElement
Optional. This attribute is deprecated; theelementType
attribute takes precedence over this attribute. Iftype
isArray
, this attribute specifies whether the elements in the array are DOM elements. Set totrue
to specify that the elements are DOM elements; otherwise, set tofalse
. If theelementType
attribute is not set andelementDomElement
is set totrue
, IntelliSense treats each element in the array as anHTMLElement
when performing statement completion.elementMayBeNull
Optional. Iftype
isArray
, specifies whether the elements in the array can be set to null. Set totrue
to indicate that the elements in the array can be set to null; otherwise, set tofalse
. The default value isfalse
. This attribute is not used by Visual Studio to provide IntelliSense information.helpKeyword
Optional. The keyword for F1 Help.locid
Optional. The identifier for localization information about the variable. The identifier is either a member ID or it corresponds to thename
attribute value in a message bundle defined by OpenAjax metadata. The identifier type depends on the format specified in the <loc> tag.description
Optional. A description of the variable.
Example
The following code example shows how to use the <var>
element.
/// <var>A rectangle that has a width of 5.</var>
var Rectangle = {
/// <field type = 'Number'>The width of the rectangle.</field>
wid: 5,
/// <field type = 'Number'>The length of the rectangle.</field>
len: 0,
/// <field type='Number'>Returns the area of the rectangle.</field>
getArea: function (wid, len) {
return len * wid;
}
}