JavaScript Operators

Javascript operators are symbols or keywords which perform certain actions when added to a particular expression. For example, the add (+) symbol is an arithmetic operator that is used to add two variables, while the greater-than (>) or less-than (<) symbols are the comparison operators that tells the JavaScript engine to compare two values.

  1. Assignment Operators
  2. Arithmetic Operators
  3. Comparison Operators
  4. Conditional (or ternary) Operators
  5. Logical (or Relational) Operators

Javascript Assignment Operators

var x = 10;

Javascript Arithmetic Operators

Adding Operators

var x = 5;
var y = 2;
var z = x + y;

Multiplying Operators

var x = 5;
var y = 2;
var z = x * y;

Javascript Comparison Operators

var x = 2;
var y = 9;
if(y>x)
{
document.write("y is greater.");
}
else
{
document.write("x is greater.");
}

Leave a Reply

Your email address will not be published. Required fields are marked *