Left shift operator (<<)
The << operator shifts bits to the left. For Number it operates on signed 32-bit integers and reduces the shift count modulo 32. BigInt has neither restriction; both operands must have matching numeric types.
CKTIS / JavaScript
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The << operator shifts bits to the left. For Number it operates on signed 32-bit integers and reduces the shift count modulo 32. BigInt has neither restriction; both operands must have matching numeric types.
The `<<=` operator shifts a value's bits to the left and assigns the result to the target. The value stored in the target can differ from the shift result. The shift uses 32 bits for `Number` but does not truncate `BigInt` results to 32 bits.
The <= operator compares two operands and returns a Boolean when evaluation completes normally. It includes the boundary value, but type conversions and NaN require care.
The < operator checks whether its left operand is smaller than its right operand. It compares numbers or strings, may perform type conversions, and returns true or false when it completes normally.
The && operator evaluates its left operand and evaluates the right operand only when the left is truthy. It returns one operand's value, which is not necessarily true or false.
The &&= operator evaluates the right-hand side and assigns its value only when the target's current value is truthy. Otherwise, it skips both the right-hand side and the write.
The ! operator converts its operand to a Boolean and reverses it. It returns true for falsy values and false for truthy values. Double negation, !!, produces a Boolean without reversing its meaning.
The || operator returns its left operand if it is truthy; otherwise, it evaluates and returns its right operand. It short-circuits and does not necessarily return a Boolean.
The ||= operator assigns the right-hand value only when the target's current value is falsy. It short-circuits evaluation and evaluates the target reference only once.
The * operator computes the product of two values after numeric conversion. It supports Number and BigInt but does not allow mixing those types. Number multiplication requires attention to rounding and NaN.
The *= operator multiplies a variable's or property's current value by the right operand and assigns the computed product. The expression yields that product, which may differ from the value actually stored. The operator supports Number and BigInt but does not allow mixing those types.
The ??= operator assigns only when the target contains null or undefined. It preserves 0, false, and the empty string.
The ?? operator selects its right operand only when the left one is null or undefined. It preserves valid zero, false, and empty-string values.
Optional chaining stops access when the checked base is null or undefined. It returns undefined instead of evaluating the remainder of that chain.
Property access uses a dot or square brackets. Dot notation selects a fixed name, while bracket notation evaluates a property key, for example from a variable's value.
The % operator computes a remainder for Number or BigInt values. A nonzero result has the dividend's sign, so negative inputs distinguish remainder from nonnegative modulo. Operand types and division by zero need special attention.
The %= operator calculates the remainder of the current value divided by the right operand and stores the result in the same target. It supports Number and BigInt; remainder is not the same as always-nonnegative modulo.
The >> operator shifts bits right while preserving the sign. For Number it operates on signed 32-bit integers; for BigInt it does not restrict values to 32 bits. The shift-count rules differ between these types.
The >>= operator shifts bits right while preserving the sign and writes the result back to its left operand. It supports Number and BigInt, with different rules for numeric width and shift counts.
The `...` notation has two context-dependent roles: spread expands values or properties, while rest collects remaining arguments, elements, or properties. It is not a standalone expression operator. Copies made with this syntax are shallow.
The === operator compares values without converting different types to make them match. It returns a boolean: true or false.
The !== operator checks whether two values are not strictly equal, without type conversion. It returns a Boolean; when comparing objects, identity matters rather than contents.
The binary `-` operator subtracts the right operand from the left. It converts operands to numeric values and supports either `Number` or `BigInt`, but does not allow those types to be mixed.
The -= operator subtracts the right operand from the current value of the left operand and stores the result in the same location. It performs numeric conversion, and the whole expression returns the assigned value.