Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Warning: Conditional compilation is not supported in Internet Explorer 11 Standards mode and Windows 8.x Store apps. Conditional compilation is supported in Internet Explorer 10 Standards mode and in all earlier versions.

The @set statement creates variables used with conditional compilation statements.

Syntax

@set @varname = term

Parameters

varname
Valid JavaScript variable name. Must be preceded by an "@" character at all times.
term
Zero or more unary operators followed by a constant, conditional compilation variable, or parenthesized expression.

Remarks

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 NaNNaN can be checked for using the @if statement:

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

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

Requirements

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

See Also

Document Tags and Contributors

Contributors to this page: ExE-Boss, khorne3, erikadoyle
Last updated by: ExE-Boss,