Skip to content

Latest commit

 

History

History
48 lines (30 loc) · 898 Bytes

primitive-data-types.md

File metadata and controls

48 lines (30 loc) · 898 Bytes

Javascript primitive data types

There are 7 primitive data types in Javascript.

  • Number
  • String
  • Boolean
  • Null
  • Undefined
  • Symbol

Number

  • Integer - 1
  • Floating point - 1.1
  • Infinity - Infinity

String

  • Single quote - 'Hello'
  • Double quote - "Hello"
  • Backtick - `Hello`

Boolean

  • true
  • false

Null

  • null

Undefined

  • undefined

Symbol

  • Symbol('Hello')

NOTE: Since all numbers are stored in a 64-bit floating-point format (IEEE 754 standard), there is a limit to how big a number can be. Javascript integers are only accurate up to 15 digits (53 bits). To store larger numbers, you can use the BigInt data type.

BigInt

To create a BigInt, you can add an n at the end of the number or use the BigInt() function.

  • 1234567890123456789012345678901234567890n
  • BigInt(1234567890123456789012345678901234567890)