JavaScript data types

summarizing the building blocks of web app data
// updated 2025-05-02 07:11

We can categorize basic data types, known as primitives, as follows:

  • Number
  • String
  • Boolean
  • null
  • undefined
  • Object

Number

A value we can calculate with another

  • an integer like 3, -1, 0
  • a floating point number like -273.15

String

A value with one or more alphanumeric characters

  • plain text like String or Hello, World!
  • plain text that has non-calculatable numbers like Price: $200
    • if we try to add a String that has 2 and another String that has 2 we willl get 22 instead of 4

Boolean

A value of binary logic (either true or false)

  • usually to test some logic statement like 2 == 2 (2 is equal to 2)
  • named after George Boole, a 19th century logician

null

A placeholder value that indicates that no value exists

  • still considered a value

undefined

A response signifying the absolute lack of a value

  • implies that no value exists, not even null

Object

A value with a structure that consists of a set of properties (with each property having a name and a value), e.g.

var myObject = {
  username: "Jon",
  age: 100,
  alive: true  
}

As we can see in the example above, each property itself has values that consist of the primitive data types of string, number and Boolean.

From this point, we can work with these objects (that consist of values of primitive data types) to make a representation of some facet of reality!

⬅️ older (in textbook-javascript)
📒 JavaScript on the browser console
newer (in textbook-javascript) ➡️
JavaScript strings 📒
⬅️ older (in code)
📒 JavaScript on the browser console
newer (in code) ➡️
JavaScript strings 📒
⬅️ older (posts)
📒 JavaScript on the browser console
newer (posts) ➡️
JavaScript strings 📒