Various kinds of data types in JavaScript and their utility

Various kinds of data types in JavaScript

JavaScript (JS) is a lightweight, interpreted or JIT compiled programming language with first-class functions. It's a prototype-based, multi-paradigm, dynamic scripting language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles. It is open and cross-platform. It is integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. Most well-known as the scripting language for Web pages, many non-browser environments also use it, such as node.js and Apache CouchDB.

JavaScript was first known as LiveScript, but Netscape changed its name to JavaScript, possibly because of the excitement being generated by Java. JavaScript made its first appearance in Netscape 2.0 in 1995 with the name LiveScript. The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers.

Programming languages that allow such things are called “dynamically typed”, meaning that there are data types. There are seven data types in JavaScript.

Let's see -


The number type serves both for integer and floating point numbers. There are many operations for numbers, e.g. multiplication *, division /, addition +, subtraction - and so on. Besides regular numbers, there are so-called “special numeric values” which also belong to that type: Infinity, -Infinity and NaN (Not-a-Number).

  • "Infinity" represents the mathematical Infinity ∞. It is a special value that’s greater than any number.

  • "NaN" represents a computational error. It is a result of an incorrect or an undefined mathematical operation.


A string (or a text string) is a series of characters. Strings are written with quotes. You can use single or double quotes. You can use quotes inside a string, as long as they don't match the quotes surrounding the string.


The Array lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type. JavaScript arrays are written with square brackets. Array items are separated by commas. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. The Array parameter is a list of strings or integers. When you specify a single numeric parameter with the Array constructor, you specify the initial length of the array. The maximum length allowed for an array is 4,294,967,295.


Booleans can only have two values: true or false. Booleans are often used in conditional testing. If the value parameter is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (" "), the object has an initial value of false.


JavaScript objects are written with curly braces. Object properties are written as name:value pairs, separated by commas. Objects are the most complex data type.


In JavaScript, a variable without a value has the value undefined. The type is also undefined. Any variable can be emptied, by setting the value to undefined. The type will also be undefined.


In JavaScript null is "nothing". It is supposed to be something that doesn't exist. Unfortunately, in JavaScript, the data type of null is an object. You can empty an object by setting it to null.

Empty Values

An empty value has nothing to do with undefined. An empty string has both a legal value and a type.


Symbols are new to JavaScript in ECMAScript 2015. A Symbol is a unique and immutable primitive value and may be used as the key of an Object property (see below). In some programming languages, Symbols are called atoms.

The typeof operator

The typeof operator returns the type of the argument. It’s useful when we want to process the values of different types differently, or just want to make a quick check. You can use the JavaScript typeof operator to find the type of JavaScript variable. It supports two forms of syntax:

  • As an operator: typeof x.

  • Function style: typeof(x).

In other words, it works both with parentheses or without them. The result is the same.


Photograph by Eny Setiyowati

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!