JS Series: EP. (IV) — May the “Data types” be with you.

This is the Fourth article of the Javascript Starwars series So let’s get started with “variables”.

Code cutters
2 min readDec 14, 2022

What are “Data types”?

In Javascript, data types tell us what kind of data structure it is. As we know variables can be assigned (and re-assigned) any value in javascript. Hence we call javascript a dynamically typed language. In total there are 8 data types in JavaScript -

Numbers, BigInt, Strings, Boolean, Null, Undefined, Objects, Symbols

Note: Arrays do not belong to this list because they are objects as well.

To check type of a data type we use special operator in js called “typeof”

example -
console.log(typeof “ABC”); // “string”
console.log(typeof (“ABC”)); // “string”

typeof is not a function it is just a special operator in js which returns a string as a type of data…

Also, it is not a rule that typeof always return data type from those 8 ones check the * Examples below -

A quick comparison of all 8 datatypes

typeof undefined // "undefined"
typeof 0 // "number"
typeof 10n // "bigint"
typeof true // "boolean"
typeof "foo" // "string"
typeof Symbol("id") // "symbol"
typeof Math // "object" *
typeof null // "object" *
typeof alert // "function" *

Types of data types

There are two types of data types in javascript:

  • Primitive:- (String, Boolean, Number, BigInt, Null, Undefined, Symbol )
  • Non-Primitive:- Object (array, functions) also called object references.

The fundamental difference between primitives and non-primitive is that primitives immutable and non-primitive are mutable.

  • Mutable values are those which can be modified after creation.
  • Immutable values are those which cannot be modified after creation.

So yeah, That was a quick intro about “data types” More learnings ahead…

Stay Tuned for the next Episode. Thanks.

✍️ Medium — codecutters.medium.com ☕️ Buymeacoffee — buymeacoffee.com/codecutters
🦄 Hash node — codecutters.hashnode.dev
❤️ Youtube — https://www.youtube.com/@codecutters/

Ya ya, you going… I know, and haven’t followed me yet? no problemo.
Just kidding Please “Like share and Follow” until your hands are tired…

ha ha ha … May the javascript be with you :)

--

--

Code cutters
Code cutters

Written by Code cutters

Making coding strong. From Basics to the Latest trends. 🚩 Advanced Frontend 🚀 Web Performace 🙊 NocodeLowcode 🧠 DSA Problem Solving ⏳ Interview Prep.

No responses yet