#JS from Start- Data types in JavaScript

in GitPlait3 months ago

There are various types of data in JavaScript, but the mains are the Primitive data and Reference data.
There are lots of things to say about primitive and reference but I don’t want to confuse you. Primitive Data Types are data that are stored directly on the stack. This means when you access primitive data, you access it by its values. Reference data are accessed by reference and stored on the heap of the memory.

Primitive data

  • String (Letters, numbers, symbols and a few others.)
  • Boolean
  • Number(Integals, decimals, float are all numbers)
  • Undefined
  • Null
  • Symbols (Introduced in ES6)

Reference Data

  • Arrays
  • Object Literals
  • Dates
  • Functions
  • Others

So, we will start by creating some variables with different types.

PRIMITIVE DATA TYPES

String

Number

Boolean

Null

The output here is object, but Null is not an Object. It is mistake in the JavaScript. It is a primitive.

Undefined

Symbols

REFERENCE DATE TYPES

All reference types are object.

Array

Object Literal

Date

I will stop here now. I will talk about functions at a better applicable section and we will loot at Type conversion on Saturday.

Thank you!

cover image-tykee-03.png

Sort:  

@tipu curate 2 :)

Upvoted 👌 (Mana: 7/21)

Thank you!