<param> (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 parameter in a function or method.
Syntax
<param name="parameterName" type="ParameterType"
integer="true|false" domElement="true|false"
mayBeNull="true|false" elementType="ArrayElementType"
elementInteger="true|false" elementDomElement="true|false"
elementMayBeNull="true|false" locid="descriptionID"
parameterArray="true|false" optional="true|false"
value="code">description
</param>
Parameters
name
Required. The name of the parameter.
type
Optional. The data type of the parameter. The type can be one of the following:
An ECMAScript language type 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 parameter is an integer. Set totrue
to indicate that the parameter 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 parameter is a DOM element. Set totrue
to specify that the parameter is a DOM element; otherwise, set tofalse
. If thetype
attribute is not set anddomElement
is set totrue
, IntelliSense treats the documented parameter as anHTMLElement
when performing statement completion.mayBeNull
Optional. Specifies whether the documented parameter can be set to null. Set totrue
to indicate that the parameter 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.locid
Optional. The identifier for localization information about the parameter. 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> element.parameterArray
Optional. Specifies whether the documented parameter can be repeated in the function call, similar to repeating parameters supported in theString.format
function. Set totrue
to indicate that the parameter can be repeated; otherwise, set tofalse
. This attribute is not used by Visual Studio to provide IntelliSense information.optional
Optional. Specifies whether the documented parameter is optional in the calling function. Set totrue
to indicate that the parameter is optional; otherwise, set tofalse
.value
Optional. Specifies code that should be evaluated for use by IntelliSense instead of the function code itself. You can use this attribute is to provide type information when the parameter type is undefined. For example, you can usevalue=’1’
to treat the parameter type as a number.description
Optional. A description of the parameter.
Remarks
The only required attribute is name
. All other attributes are optional.
Elements used to annotate functions, such as <summary>, <param>, and <returns>, must be placed in the function body before any statements.
If there are multiple <param>
elements that have the same name, one of the <param>
elements is used and the redundant elements are ignored. The behavior that determines which element is used is not defined. If name
refers to a nonexistent parameter, the element is ignored.
Example
The following code example shows how to use the <param>
element.
function areaFunction(radiusParam)
{
/// <summary>Determines the area of a circle when provided a radius parameter.</summary>
/// <param name="radiusParam" type="Number">The radius of the circle.</param>
/// <returns type="Number">The area.</returns>
var areaVal;
areaVal = Math.PI * radiusParam * radiusParam;
return areaVal;
}
// Uses of <param> with the value attribute.
function calculate(a) {
/// <param name='a' value='1'/>
a. // Completion list for a Number.
}
function calculate(a) {
/// <param name='a' value='{x:0,y:0}'/>
a. // x and y appear in the completion list.
}