Home  >  Q&A  >  body text

a++与++a的区别在哪?

不是说++在后的事先运算再赋值,运算会影响结果,当++a是先赋值在运算,运算结果不改变么?只是a的值变了?

看山看水看代码看山看水看代码2863 days ago1552

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 22:44:59

    What is the difference between a++ and ++a? -PHP Chinese website Q&A-What is the difference between a++ and ++a? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 阿神

    阿神2016-12-17 12:00:23

    有区别啊,比如var b = 1;a=b++;c=++b;

    那运算完之后

    a=1;(b先参与运算,将值赋给a,然后自己再加1,所以a为1,b为2)

    c=3;(b为2,然后先自己加1,再将值赋给c)

    reply
    0
  • Cancelreply