TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
** operator is the exponentiation operator in TypeScript, evaluating to the result of raising the left operand (base) to the power of the right operand (exponent). While mathematically equivalent to Math.pow(), the ** operator natively supports both number and bigint operands. In contrast, Math.pow() strictly accepts number types; passing a bigint to Math.pow() results in a TypeScript compile-time error (Argument of type 'bigint' is not assignable to parameter of type 'number').
Type Constraints and BigInt Behavior
TypeScript enforces strict type checking on the operands. Both the base and the exponent must be of typenumber or bigint, and both operands must be of the exact same type. Mixing types will result in a compiler error.
Furthermore, when using bigint operands, the exponent must be non-negative. Because the bigint type cannot represent fractional values, evaluating a bigint base with a negative bigint exponent throws a runtime RangeError.
Associativity
Unlike most binary operators in TypeScript (which are left-associative), the** operator is right-associative. Multiple exponentiation operations in a single expression are evaluated from right to left.
Precedence and Unary Operators
The** operator has a higher precedence than standard arithmetic operators (*, /, +, -). However, TypeScript enforces a strict parsing rule: a unary operator (such as -, +, ~, !) cannot immediately precede the base operand of an unparenthesized exponentiation expression. This prevents ambiguity regarding whether the unary operator applies to the base or the evaluated result.
Compound Assignment
The operator includes a compound assignment variant,**=, which applies the exponentiation operation to a variable and assigns the result back to that variable.
Master TypeScript with Deep Grasping Methodology!Learn More





