JavaScript Primitive & Non Primitive Data Type

javascript-primitive-&-non-primitive-data-type

Normally when we hear data types in any programming language, integer, string, etc… jumps to our mind.

Although all of these things are data types, there are two umbrellas contains most of the JavaScripts data types.

Primitive Data Types & Non Primitive Data Types

Non Primitive Data Types

  1. Array which is used for storing different elements,
    Ex:
arr = [1, 3, 5, 'jack']
  1. Object which is a standalone entity, with properties and type,
    Ex:
client = {
  name: "Harry Potter",
  age: 20,
  eyeColor: "blue"
};

Primitive Data Types

  1. Number which is used for floating-point numbers,
    Ex:
num = 1;
  1. String which is used for sequence of characters,
    Ex:
name = 'Mike';
  1. Boolean which is used for logical type that can be only true or false,
    Ex:
flag = true;
  1. Undefined which is used for a variable that got declared and yet not assigned to a value (empty value),
    Ex:
value;
console.log(value)     // undefined
  1. Symbol (ES2015) which is used for value that is unique & cannot be changed,
    Ex:
client = {
  name: "Harry Potter",
  age: 20,
  eyeColor: "blue"
};
id = Symbol('id');
client[id] = 101959; // you added an id to client named 'Harry Potter'
  1. BigInt (ES2020) which is used for larger integers than the number type can hold,
    Ex:
bigNum = BigInt("123456789012345678901234567890123456789");

Note:

in both the array & the object can contain different types of data.

Total
1
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
how-to-deploy-an-aws-lambda-stack-under-a-custom-domain-name

How to deploy an AWS Lambda Stack under a custom domain name

Next Post
quntis-screen-light-bar-vs.-benq-screenbar

Quntis Screen Light Bar Vs. BenQ ScreenBar

Related Posts