This topic has not yet been rated - Rate this topic

@set Statement (JavaScript)

JavaScript - Internet Explorer 10

Creates variables used with conditional compilation statements.

Caution note Caution

Conditional compilation is supported in Internet Explorer only, not in Windows Store apps.

@set @varname = term 
varname

Required. Valid JavaScript variable name. Must be preceded by an "@" character at all times.

term

Required. Zero or more unary operators followed by a constant, conditional compilation variable, or parenthesized expression.

Numeric and Boolean variables are supported for conditional compilation. Strings are not. Variables created using @set are generally used in conditional compilation statements, but can be used anywhere in JavaScript code.

Examples of variable declarations look like this:

@set @myvar1 = 12

@set @myvar2 = (@myvar1 * 20)

@set @myvar3 = @_jscript_version

The following operators are supported in parenthesized expressions:

  • ! ~

  • * / %

  • + -

  • << >> >>>

  • < <= > >=

  • == != === !==

  • & ^ |

  • && | |

If a variable is used before it has been defined, its value is NaN. NaN can be checked for using the @if statement:

@if (@newVar != @newVar)
   ...

This works because NaN is the only value not equal to itself.

Supported in all versions of Internet Explorer, but not in Windows Store apps.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.