DEV Community

Phuong-Cat Ngo
Phuong-Cat Ngo

Posted on • Edited on

JavaScript Data Types

Understanding the different types of data that can be used in JavaScript is essential for building reliable and efficient programs. In this blog post/quick lecture notes, we'll briefly explore the different types of JavaScript data types.

Primitive

Primitives are data types that do not have named attributes. They do not have methods or properties either.

The Seven Primitive Data Types are:

  1. String - representation of a sequence of characters enclosed in single (') or double (") quotes
    let str = "abc"

  2. Number - numeric values that are integers or floating-point numbers
    let num = 5

  3. BigInt - whole number larger than the maximum safe number a Number variable or data type can have
    let bigInteger = Number.MAX_SAFE_INTEGER

  4. Boolean - true or false value that represents a logical entity
    let bool = true

  5. Undefined - variable that has not been assigned a value
    let undefinedValue

  6. Symbol - unique identifier (rarely used from what I gathered from the lecture)
    let sym = Symbol()

  7. Null - represents a value that does not exist or is invalid

Source

Structured

Structured means that it has one or more named attributes. It can have methods or properties, unlike primitive data types.

  1. Objects - a collection of key-value pairs which can also be called map, dictionary, or hash-table in other languages. Arrays are considered an object.

let oj { id: 1, name: cat}

Fun fact: Functions are also considered an Object type! See 4.3.31 in ECMA International for terms and definitions.

There might be more examples of structured data types compared to what I went over. However, this is just the beginning! I am super excited to learn more about JavaScript.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay