JavaScript Self increasing 、 Subtraction operator and expression syntax

var i++;
  • var-- Declare variables
  • i-- Variable name
  • ++ -- Self - increment operator

JavaScript Self increasing 、 Subtraction operators and expressions

JavaScript Self increasing 、 Subtraction operators and expressions (i The initial value is 6)
Operator ++i --i i++ i--
name Pre autoincrement operator The pre minus operator Post autoincrement operator Post subtraction operator
expression ++i --i i++ i--
Example ++i; --i; i++; i--;
i Result 7 5 7 5
Interesting examples ++i
alert(i)
alert(++i)
alert(i)
--i
alert(i)
alert(--i)
alert(i)
i++
alert(i)
alert(i++)
alert(i)
i--
alert(i)
alert(i--)
alert(i)
result 7
8
8
5
4
4
7
7
8
5
5
4

Example explanation

There is an essential difference between the former autoincrement operator and the latter , What they have in common is that they add 1, The difference is that the former autoincrement operator is the first addition 1, Reuse the value of the operands , The latter autoincrement operator uses the value of the operands first , add 1. for example :

var a;
var i=6; //( Add... Before )i Add 1 after ,i be equal to 7, And will i Value assignment a, therefore a be equal to 7
a=++i;
document.write(i);
document.write(a); i=6;
//( Add after ) take i Value assignment a, therefore a be equal to 6, Last i Add 1,i be equal to 7
a=i++;
document.write(i);
document.write(a);

result

7
7
7
6

JavaScript Self increasing 、 More articles about self subtraction

  1. javascript The typical operation of self increasing and self decreasing ( Fallible )

    JavaScript“ Self increasing ” Operators and expressions Increment operator (++) Is a unary operator , This operator can increment the operands , That is to say, increase each time 1. Increment operators require that their operands be variables . An attribute in an object or an element in an array , and ...

  2. Javascript Self increasing 、 Self - subtracting operator

    JavaScript Self increasing . Subtraction operator and expression syntax var i++; var-- Declare variables i-- Variable name ++ -- Self - increment operator JavaScript Self increasing . Subtraction operators and expressions JavaScript Self increasing ...

  3. javascript summary 11:JavaScript Of  Increase and decrease

    1  Increase and decrease 1.1 Self increasing writing method i++ effect : Without taking part in the calculation ,i++ and ++i It's all based on variables 1 var n1 =123; //n1++ Equivalent to n1 = n1 +1; ++n1 // Equivalent to n1 ...

  4. 【 turn 】 C In depth analysis of language self increasing and self decreasing operators

    from :http://bbs.csdn.net/topics/330189207 C The growth of language ++, Self reduction -- Operators have always been a problem for beginners , Even a lot of veterans are confused , Recently I saw a question on the Internet :#in ...

  5. C++ Primer Learning notes _61_ Overloaded operators and transformations -- Self increasing / Self - subtracting operator

    Overloaded operators and transformations -- Self increasing / Self - subtracting operator introduction : Self increasing , Self subtraction operators are often implemented by classes such as iterators , This class provides pointer like behavior to access elements in a sequence . such as , Be able to define a class , This class points to an array and provides access to the elements in the array ...

  6. C: printf The influence of parameter execution sequence and pre post auto increment auto decrement

    origin : Today we're looking at the side effects side-effect In the process of , See the page below , It took me to printf A series of problems caused by , All day long , Barely understand . The first code has nothing to explain . And the second one. printf(" ...

  7. esxi The solution to the problem is to simplify the equipment ( turn )

    esxi The solution to the problem is to simplify the equipment as everyone knows Thin Provisioning The disk space of the virtual machine in mode will grow as needed , It can help us save space to a great extent , But , All the space after growth , Even after clearing the files that caused the growth ...

  8. Java Basic knowledge of —— arithmetic operator 、 Increase and decrease 、 Relational operator , Do you really understand ?

    company , I must learn from you . Welcome to my WeChat yh18482155461, Or scan the qr code below , Pay attention to my WeChat official account , Discuss together Java Related technical issues . View of We saw that in the last video Java The assignment operator in , In the form of cases ...

  9. [c/c++] programming The way (8)、 assembly 、 modulus 、 Increase and decrease

    One . Insert assembly #include<stdio.h> void main(){ ; num=num+; // Insert assembly language _asm{ mov eax,num;//eax It's a memory , take num Of ...

Random recommendation

  1. redis-cli Some of the practical little functions that we may not know about

    Yes redis Our friends all know ,redis One of them is called redis-cli Gadgets , We can use it in test and develop Efficient simulation test under the environment , But in the real world , All we know is to type in redis-cli ...

  2. wordpress And its simple_press Plug in complete Chinese Forum of

    wordpress And Its simple_press The forum function of the plug-in The development of preparation : Have been engaged in java And as3 Aspect development , It's the first time I've heard a colleague mention PHP Of wordpress, So I checked it on the Internet , Just know the power of this software , conversely ...

  3. plain framework 1 Reference manual Introduction to the introductory guide

    brief introduction brief introduction What can be done ? LINUX WINDOWS brief introduction Simple frame (plain framework) It's based on C/C++ Developed , Cross platform (windows/linux) Basic framework of application , Developers can take advantage of this framework ...

  4. Found a new installation Android SDk Methods - Record

    This method needs to use domestic image , But the domestic image network speed does not have to be very fast . Thunderbolt download tool this is a must . I noticed today that SDK There is a temp Folder , Open it and see that it is the cache directory , So I want to download the corresponding package directly from the mirror station to replace , measuring ...

  5. Using innodb_large_prefix to avoid ERROR #1071,Specified key was too long; max key length is 1000 bytes

    Using innodb_large_prefix to avoid ERROR 1071        Single column index limit mentioned above 767, The cause is 256×3-1. This 3 Is the maximum space occupied by characters (ut ...

  6. C# Take the decimal point

    1.Math.Round(0.333333,2);// According to the international standard of rounding 2. double dbdata=0.335333; string str1=String.Format("{0: ...

  7. CXF Development WebService

    What is? CXF: Apache CXF = Celtix + Xfire Support multiple protocols : SOAP1.1,1.2 XML/HTTP CORBA(Common Object Request Broker ...

  8. Unity Summary of personal used ground testing programs

    Unity Summary of personal used ground testing programs 1. Ordinary rays In character coordinates ( It's usually the sole of the foot ), Shoot a downward ray , The length is about 0.2, Simple terrain only , In practice, we often encounter the following problems With collider When we hit the ground , ...

  9. MyBatis+Spring SQL Efficiency test report

    1. database structure 2. insert test insert Our tests include 1) Batch splicing values() Insert 2) Affairs for Circular insert 3) No transaction for Circular insert test SQL: <!-- Ordinary ...

  10. erlang -- ios&#160;apns&#160;provider&#160;--&#160;erlang&#160; Realization

    os apns-apple notification server With a third party provider There are many introductions on the Internet , I won't introduce , You can go if you want to know IOS Official website https://developer. ...