JavaScript Operators
Operators do the actual work in an expression — comparing values, combining them, checking types. This includes everyday symbols like === and the ones that trip people up: optional chaining (?.), nullish coalescing (??) and the spread syntax (...). Browse all 29 below, each with a clear explanation and live examples.
| Name | Description |
|---|---|
| + | Adds numbers — but also concatenates strings, which causes the classic type-coercion gotchas. |
| => | A short syntax for writing functions that also inherits this from the surrounding scope. |
| = | Assigns a value to a variable. Not to be confused with == or === (comparison). |
| delete | Removes a property from an object. Not for deleting variables or array elements cleanly. |
| destructuring | Unpacks values from arrays or properties from objects into distinct variables in one step. |
| / | Divides one number by another. Dividing by zero gives Infinity, not an error. |
| ** | Raises the left operand to the power of the right. A concise alternative to Math.pow(). |
| > | Tests whether the left value is greater than the right. Works on numbers and, alphabetically, strings. |
| >= | Tests whether the left value is greater than or equal to the right. |
| in | Tests whether a property (or array index) exists in an object, returning true or false. |
| != | Tests whether two values are not equal, after type coercion. Prefer !== instead. |
| instanceof | Tests whether an object was created from a particular constructor or class. |
| < | Tests whether the left value is less than the right. Numeric for numbers, alphabetical for strings. |
| <= | Tests whether the left value is less than or equal to the right. |
| && | Returns the first falsy value or the last value. Short-circuits, and is used for conditional execution. |
| ! | Inverts a boolean. The double form (!!) converts any value to a real true/false. |
| || | Returns the first truthy value or the last value. Short-circuits, and was the classic default-value operator. |
| == | Compares two values for equality after converting their types. Prefer === to avoid surprises. |
| * | Multiplies two numbers, coercing string operands to numbers. |
| new | Creates an instance of a class or constructor function, running its constructor. |
| ?? | Returns the right-hand value only when the left is null or undefined — a safer default than ||. |
| ?. | Safely accesses nested properties, returning undefined instead of throwing if something is missing. |
| % | Returns the remainder after dividing one number by another. Used for even/odd and wrapping. |
| ... | Expands an array, object or iterable into individual elements. Also used for rest parameters. |
| === | Compares two values for equality without type conversion. The equality check you should use. |
| !== | Tests whether two values are not equal, without type coercion. The not-equal you should use. |
| - | Subtracts one number from another, and as a unary operator negates or converts to a number. |
| ?: | A compact one-line if...else that chooses between two values based on a condition. |
| typeof | Returns a string naming the type of a value, such as "string", "number" or "object". |