AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

JavaScript Operators


JavaScript Tutorial » JavaScript Operators

Operators are symbols or keywords that tell JS to perform some sort of actions.

Arithmetic Operators
Example, the addition (+) is an operator that tells JS to add two variables or values.

+ Addition: $a + $b Sum of $a and $b
- Subtraction: $a - $b Difference of $a and $b.
* Multiplication: $a * $b Product of $a and $b.
/ Division: $a / $b Quotient of $a and $b
% Modulus: $a % $b Remainder of $a divided by $b

Example:
<script>
var a = 12;
var b = 6;

alert(a + b); // 0utputs: 18
alert(a - b); // 0utputs: 6
alert(a * b); // 0utputs: 72
alert(a / b); // 0utputs: 2
alert(a % b); // 0utputs: 2


Assignment Operators - example


Are used to assign values to variables.

= Assign a = b a = b
+= Add and assign a += $ a = a + b
-= Subtract and assign a -= b a = a - b
*= Multiply and assign a *= b a = a * b
/= Divide and assign quotient a /= b a = a / b
%= Divide and assign modulus a %= b a = a % b

Example:

<script>
var a; // Declaring Variable

a = 22;
alert(a); // Outputs: 22

a = 25;
a += 40;
alert(a); // Outputs: 65

a = 72;
a -= 22;
alert(a); // Outputs: 50

a = 6;
a *= 11;
alert(a); // Outputs: 66

a = 66;
a /= 11;
alert(a); // Outputs: 6

a = 100;
a %= 15;
alert(a); // Outputs: 10

</script>



JavaScript Operators list, mozilla, precedence, cheat sheet, priority, and expressions, exercices

JavaScript Operators list, mozilla, precedence, cheat sheet, priority, and expressions, exercices
JavaScript Operators - javascript tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.