CKTIS / JavaScript
Hexadecimal numeric literal
A hexadecimal numeric literal writes a number in base 16 using the prefix 0x or 0X. Without a suffix it creates a Number value; the n suffix indicates BigInt.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
0x<hex-digits> or 0X<hex-digits> for Number; append n for BigInt. <hex-digits> contains one or more digits from 0–9, a–f, or A–F. A single underscore (_) may separate any two adjacent digits in either form, as in 0xFF_FF and 0xFF_FFn.A hexadecimal numeric literal (Hexadecimal numeric literal) is a number written directly in source code in base 16. The prefix 0x or 0X must be followed by at least one digit from 0–9, a–f, or A–F. Letters represent values from 10 to 15; letter case does not change the value.
The notation 0x2A means 2 * 16 + 10, or 42. Without a suffix, the literal creates a Number value, not a separate hexadecimal type. Consequently, 0x2A === 42 is true. The notation's base is not retained as a property of the value.
The suffix n, as in 0x2An, creates a BigInt. Hexadecimal notation alone does not increase Number precision: outside the safe integer range, exactness is not guaranteed. Use BigInt when you need exact large integers.
Do not confuse the literal 0x2A with the string "0x2A". A hexadecimal literal cannot contain a fractional part or an exponent; e and E are digits with value 14 here. The example demonstrates equivalent notations and the distinction between Number and BigInt.
Examples
const value = 0x2A;
console.log(value);
console.log(value === 42);
console.log(0Xff === 255);
console.log(typeof value);
console.log(typeof 0x2An);Result
42 true true number bigint
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.