Data types in JavaScript

Welcome to everyone to my first tech blog on the fundamentals of Javascript language. In this blog, we will show the different data types in Javascript language according to the current ECMA Script Standard.

We know Javascript is a dynamically typed language, which means you don’t need to specify types of the variable because dynamically used by the Javascript Engine. You use a Javascript variable to specify the data type and it can hold any data type of value like Numbers, Strings, Boolean, etc.

What is Data type ?

According to Wikipedia — “Data type is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and a representation of these values as machine types”.

In Javascript, every variable has held the data types and stored the value of the variable. There are two types of data types in JavaScript first is Primitive data types and second is Non-primitive data types.

What is a primitive data type?

The primitive data types are types provided by the Javascript language. primitive data types are also known as in-build data types. These are the primitive data types in Javascript:

  • Number

What is a non-primitive data type?

The data types that are derived from primitive data of the JavaScript language are known as non-primitive data types. Non-Primitives are known as mutable data types because we can change the value after creation.

  • Object

There are the following types of primitive data types in Javascript

  1. Number

Number data types in Javascripts hold the numerical value as well as the decimal value.

var num = 10;
var num1 = 10.1;
console.log(num, num1)/// 10 10.1

2. String

String data types in Javascript have represented the sequence of textual data in single quotes or double quotes.

var name = 'Shaikh Juber'
var role = "Software Developer"
console.log(name + 'working a' + role)////Shaikh Juber working Software developer.

3. Boolean

Represented a logical entity that can have one of two values true or false.

var value = true;
console.log(value)/// true

4. Undefined

The meaning of undefined is ‘value is not assigned’.

var value;
console.log(value)////Undefined

5. Null

There is only one possible value for null which is null.

var value = null;
console.log(value)//// null

6. Symbol

The JavaScript Symbol is a function that is used to identify the object properties.

In JavaScript, there is a Symbol() function available which is used to create a value of type symbol.

There are the following Non-primitive data type in Javascript.

  1. Objects

An object in Javascript is an entity having properties and methods. Everything is an object in Javascript.

Objects are often represented the curly bracket.

let student ={
firstName: 'Shaikh',
lastName: 'Juber'
}

console.log(student.firstName + '' + student.lastName);/// Shaikh Juber

2. Array

The array is the collection of data , we can store more than one element under a single name.

var data = new Array(1, 2, "Hello", "Juber");
console.log(data)/// [1,2,'Hello','Shaikh']

I hope in this step you have fully understood all kinds of data types in JavaScript languages. If youare stuck at any point, please feel free to leave any questions, comments or feedback in the comment section below.

Follow me on Linkedin

--

--

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