Welcome to Developer's Home Wednesday, April 16, 2014
Home - DevelopersHome.com

WMLScript Assignment Operators - Assigning Values to Variables


Preferences - Do not show ads

Assignment operators are used to assign a value to a variable. One of the assignment operators, =, has been used many times earlier in this WMLScript tutorial. Its usage is very straightforward and there is nothing to explain further. Here is an example:


z = 18;

The z variable contains the value 18 after execution.


WMLScript supports a number of shortcut operators that combine arithmetic operations with value assignment operations. Below is an example of the += operator:


var z = 1;
z += 2;

After executing the above script, z contains the value 3. "z += 2;" is equivalent to "z = z + 2;".


Below is an example of the -= operator:


var z = 5;
z -= 3;

After execution, z contains the value 2. The line "z -= 3;" is equivalent to "z = z – 3;".


The following table summarizes the shortcut assignment operators available in WMLScript:


WMLScript Operator

Example

Equivalent to

+=

x += y;

x = x + y;

-=

x -= y;

x = x - y;

*=

x *= y;

x = x * y;

/=

x /= y;

x = x / y;

div=

x div= y;

x = x div y;

%=

x %= y;

x = x % y;

&=

x &= y;

x = x & y;

|=

x |= y;

x = x | y;

^=

x ^= y;

x = x ^ y;

<<=

x <<= y;

x = x << y;

>>=

X >>= y;

x = x >> y;

>>>=

x >>>= y;

x = x >>> y;


Page 19 of 71 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top
Custom Search

Feedback Form (Expand)

What do you think about this web page?






WMLScript Tutorial Table of Contents WMLScript Tutorial Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page