Home / Advanced JavaScript Tutorials / Variable and expression shortcuts

 

 

CodingForums
Having trouble with scripting? Visit our help forum to get the answers you need.

Jump to...
-Free JavaScripts
-JS tutorials
-JS Reference
-DHTML/CSS

-Free applets
-Web Tutorials
-Link to Us!

- CSS Drive
- PHP Resources
- Hotels & Vacations
- Bad credit cards
- JavaScript Menus


Red_CurlyC035.gif (995 bytes) Assignment operator shortcuts

If you write scripts that involve a lot of basic math operations (+-*/), you'll want to know the assignment operator shortcuts:

Operator: Translation:
x++ x=x+1
x-- x=x-1
x+=y x=x+y
x-=y x=x-y
x*=y x=x*y
x/=y x=x/y

Using these operators, you can replace expressions like:

x=x+y

with simply

x+=y

Quite handy, wouldn't you say?

-Tutorial introduction
-Declaring many variables at once
-Assignment operator shortcuts
-The "with" statement
-The "?" conditional expression statement

The "with" statement


http://javascriptkit.com
Copyright © 1997-2005 JavaScript Kit. NO PART may be reproduced without author's permission.