Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

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

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


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