SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Could Anyone Help Me In Js Operators ? (n00b question)

    Could anyone please explain me this?

    Image : img53.imageshack.us/img53/4722/109220224233mydesktop.png

    How x+=y is same as x=x+y ?

  2. #2
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In many programming languages, including JavaScript, '+=' is shortcut for 'x = x + y' . Don't try to apply everyday math into it. Actually, '+=' does not exist in your usual arithmetic classes at all. a programming language is a different story...

  3. #3
    SitePoint Guru hgilbert's Avatar
    Join Date
    Dec 2004
    Location
    London
    Posts
    839
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In JS you can also use:

    x -= y
    x *= y
    x /= y
    x %= y


    and all mean something like x = x (operator) y


  4. #4
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Kailash Badu, hgilbert


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •