JavaScript Data Types

Photo by Sean Lim on Unsplash

Basically in JavaScript there are two types of data . They are

1. Primitive Data Type

2. Non-primitive Data Type/ Reference Data Type

Primitive Data Types: We know everything in JavaScript is object. But primitive data types are not object or functions. Primitive data types stores values directly. This data types can be numbers, strings or among other things.

Example:

Primitive Data Types

There are 7 Primitive data types. They are : -

· Undefined: When you declare variable but don’t store value any value. This used for unintentionally missing values.

· null : This have no existence but not it’s not undefined .It’s used for intentionally missing values.

· number: It’s used for math calculation. It can be normal number, decimal numbers or even negative numbers.

· string : used for text .

· Boolean: It’s used for logical operator . It’s values are true and false.

· Symbols: used to hide implementation details.

· Bigint: used for big numbers for math.

Non Primitive Data Types: Non primitive data types don’t store values directly. They store values as references. These types of values are objects. Here are different types of data types –

· Object: used to group related data.

· Array: used for collect a group of data.

· Function: used to refer to code.

Example:

Non Primitive Data Types

Expressions: An expression is a snippet of code that can be evaluate to a value. The value may be a number, a string, or a logical value.

Example:

JavaScript Expressions

JavaScript has 3 kinds of variables. They are:

· Arithmetic expression: It’s evaluates to a number.

· String expression: It’s evaluates to character string.

· Logical expression: It’s evaluates to true or false.

Checking a Type: In JavaScript every values looks same but has different types. If you want to check the type of values it’ll return the type as string, number, Boolean, null, undefined, object, function.

Example:

--

--

--

Front End Engineer | JavaScript Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Blog Post 203

Developers’ Ultimate Dream: Kick-start Your App on ANY framework (Angular, React, Vue, Ionic…

LeetCode 70. Climbing Stairs

Build a React “Todo” App (part 2)

Redux Vs. Recoil: Why I’ve Moved from Redux to Recoil for State Management

Javascript…

How To Deploy Node.js Functions to Google Cloud.

Nuxt.js or Vue.js unit testing returns “don’t know how to turn this value into a node”

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mowmita Ahmed

Mowmita Ahmed

Front End Engineer | JavaScript Developer

More from Medium

Function in JavaScript — The Basic

Map(), Filter(), Every(), Some(), Reduce() are your best friends!

Map(), Filter(), Every(), Some(), Reduce() are your best friends!

Project #4 — Javascript

More About JavaScript, Version Controlling, NoSQL