JavaScript – Operators

JavaScript is a multi-paradigm, dynamic language with types and operators, standard built-in objects, and methods. Its syntax is based on the Java and C languages — many structures from those languages apply to JavaScript as well. JavaScript supports object-oriented programming with object prototypes, instead of classes. JavaScript also supports functional programming — functions are objects, giving functions the capacity to hold executable code and be passed around like any other object.

Operators

JavaScript has the following types of operators. This section describes the operators and contains information about operator precedence.

  • Assignment operators
  • Comparison operators
  • Arithmetic operators
  • Bitwise operators
  • Logical operators
  • String operators
  • Conditional (ternary) operator
  • Comma operator
  • Unary operators
  • Relational operators

JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binary operator requires two operands, one before the operator and one after the operator. A unary operator requires a single operand, either before or after the operator.

var x = 5; // Assignment operator
//> undefined

x < 6; // Comparison operator
//> true

x + 1; // Arithmetic operator
//> 6

"concat" + "ination" // String operator
//> "concatination"

true ? 'hey' : 'no' // ternary conditional operator
//> "hey"