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!

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

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

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.

RSS Feed RSS Feed



Follow Stephen Bucaro Follow @Stephen Bucaro


Web Design Sections

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2016 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268