DEV Community

abdulganiyy
abdulganiyy

Posted on • Edited on

2

Data Types In JavaScript

In JavaScript, there are seven data types. Six data types are primitive and one is non primitive.

PRIMITIVE DATA TYPES

  1. Number: This can be integers, decimal or floating point numbers.There are also special numbers namely; Infinity and NaN. Infinity is gotten by division with zero and NaN is as a result of incorrect mathematical operation.

  2. Strings: They represent textual data. Strings can be a single character or combination of different characters. Single quotes, double quotes begin and end strings e.g 'sugarcrush' or "sugarcrush".

  3. Boolean: Boolean values can either be True or False. A truthy value simply means yes and a falsy value means no.

  4. Null: When a null value is assigned to a variable in JavaScript, this denotes that the value is not in existence.

  5. Undefined: When a value of undefined is assigned to a variable, this denotes that a value has not been assigned to it. We can also define an undefined value by just declaring a variable without assigning it to any value or explicitly giving it a value of undefined.

  6. Symbol: Symbols are unique identifiers in JavaScript.symbol is created using Symbol() and every value created using this is unique.

NON-PRIMTIVE

Objects are the only non primitive data types in JavaScript. They are used to store key-value pairs collection of items. Objects store complex entities. It can store all the data types discussed above.

Stay tuned for more tutorials...

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

👋 Kindness is contagious

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

Okay