DEV Community


JavaScript data types

Web Developer, Sailor, Stargazer, Hockey Player, and all around fun guy... but my absolute favorite thing is being a dad
・1 min read

JS is dynamically typed. You don't have to declare a type. types are determined automatically.

Values stored in variables have types, not the variables themselves.

console.log(typeof "word") logs the type (in this case string)

typeof null returns object. This is a legacy error.

creating a string without using quotes will give you an error. let string = this creates an error logs "Uncaught SyntaxError: Unexpected identifier"


... coming soon


There are 7 primitive data types in JavaScript

  • numbers - floating point. Decimals and integers
  • strings - characters
  • boolean - true or false
  • undefined - empty values
    • let name; declaring a variable without assigning a value will have undefined as it's value
  • null - the intentional absence of any object value.
    • falsy.
  • symbol(ES2015) - guaranteed to be unique. Often used to add unique property keys to an object
  • BigInt(ES2020) - for larger integers than number can handle

Discussion (0)