Placing the increment or decrement operator in front of the variable means to increment (or decrement) the value first before using it. Placing the increment or decrement operator in after the variable means to use the value first, then increment (or decrement) it.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site

Java Script Arithmetic Operators

Java Script arithmetic operations are represented by normal mathematical notation as shown below.

Addition

var n = 13 + 24;

Subtraction

var n = 24 - 13;

Multiplication

var n = 12 * 5;

Division

var n = 12 / 4;

In each case above, the result of the arithmetic operation is assigned to the variable n.

There are several mathematical operators that you may not be familiar with.

Negation

The negation operator (-) returns the same result as multiplying the value by -1.

var m = 5;
var n = -n;

In the example above, a value of -5 is assigned to the variable n.

Modulus

The modulus operator (%) returns the remainder of a division rather than the quotient.

var n = 13 % 5;

In the example above, a value of 3 is assigned to the variable n.

Increment and Decrement

The increment operator (++) increases a value by one.

var n = 3++;

In the example above, a value of 4 is assigned to the variable n.

The decrement operator (--) decreases a value by one.

var n = 3--;

In the example above, a value of 2 is assigned to the variable n.

Web Design Sections

RSS Feed RSS Feed

Java Script Quick Reference
Java Script Data Types
Java Script Reserved Words
Java Script Arithmetic Operators
Comparison Operators
Java Script Arrays
Java Script Character Encoding and Decoding
The if/else Structure
The switch/case Structure
The for Loop
The while Loop
The break Statement
The continue Statement
JavaScript Math Object
Round a Number
Determine Absolute Value
Determine Minimum and Maximum
Generating Random Numbers
Java Script Trigonometric Methods
Java Script Number Object
Format a Number as Currency
Java Script Strings
Compare Two Strings
Find a Character or a Substring Within a String
Include a Quote Character in a String
Include a Backslash Character in a String
Define Lines in a String
Use Escape to Replace Dangerous Characters
Convert a Number to a String
Convert a String to a Number
The Document Object Model (DOM)
Accessing Web Page Elements
Interactively Set Webpage Colors
Get Webpage File Date and File Size
Dueling Windows
Cookie Power Made Easy

Self Improvement Newsletters

[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2007 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269