JavaScript Tutorial/Operators/Postfix operator

Материал из Web эксперт
Перейти к: навигация, поиск

Post-Decrement

The post-decrement operator (--) is placed to the right of a variable.

The post-decrement operator decrements the value by 1.

If the variable is a string, it is converted to a number.

2. 2. Postfix operator 2. 2. 1. <A href="/Tutorial/JavaScript/0040__Operators/PostIncrement.htm">Post-Increment</a> 2. 2. 2. Post-Decrement 2. 2. 3. <A href="/Tutorial/JavaScript/0040__Operators/Postfixoperator.htm">Postfix operator: ++</a> 2. 2. 4. <A href="/Tutorial/JavaScript/0040__Operators/Postfixoperator2.htm">Postfix operator 2: --</a>

Postfix operator: ++

   <source lang="javascript">

<html> <head> <title>A Simple Page</title> <script language="JavaScript">

</script> </head> <body> </body> </html></source>


Postfix operator 2: --

   <source lang="javascript">

<html> <head> <title>A Simple Page</title> <script language="JavaScript">

</script> </head> <body> </body> </html></source>


Post-Increment

The post-increment operator appears directly after the variable.

The operation begins by incrementing the variable by 1.

The post-increment operator returns the original value before it was incremented.

If either of the values is a string, an attempt is made to convert the string to a number.

2. 2. Postfix operator 2. 2. 1. Post-Increment 2. 2. 2. <A href="/Tutorial/JavaScript/0040__Operators/PostDecrement.htm">Post-Decrement</a> 2. 2. 3. <A href="/Tutorial/JavaScript/0040__Operators/Postfixoperator.htm">Postfix operator: ++</a> 2. 2. 4. <A href="/Tutorial/JavaScript/0040__Operators/Postfixoperator2.htm">Postfix operator 2: --</a>