JavaScript Operators Reference

JavaScript operators are used to assign values, compare values, perform arithmetic operations, and more. JavaScript Arithmetic Operators Arithmetic operators are used to perform arithmetic between variables and/or values. Given that y = 5, the table below explains the arithmetic operators: Operator Description Example Result in y Result in x Try it + Addition x = y […]

JavaScript Bitwise Operations

JavaScript Bitwise Operators Operator Name Description & AND Sets each bit to 1 if both bits are 1 | OR Sets each bit to 1 if one of two bits is 1 ^ XOR Sets each bit to 1 if only one of two bits is 1 ~ NOT Inverts all the bits << Zero […]

JavaScript Assignment

JavaScript Assignment Operators Assignment operators assign values to JavaScript variables. Operator Example Same As = x = y x = y += x += y x = x + y -= x -= y x = x – y *= x *= y x = x * y /= x /= y x = x […]

JavaScript Arithmetic

JavaScript Arithmetic Operators Arithmetic operators perform arithmetic on numbers (literals or variables). Operator Description + Addition – Subtraction * Multiplication / Division % Modulus (Remainder) ++ Increment — Decrement Arithmetic Operations A typical arithmetic operation operates on two numbers. The two numbers can be literals: Example var x = 100 + 50; Try it Yourself » or variables: Example […]

JavaScript Operators

Example Assign values to variables and add them together: var x = 5;         // assign the value 5 to x var y = 2;         // assign the value 2 to y var z = x + y;     // assign the value 7 to z (x + y) Try it Yourself » The assignment operator (=) assigns a value to a variable. Assignment var x = 10; Try […]