Need to Know about JavaScript Data Type

AR Arzu
Nov 3, 2020

Type of Values

A variable store values. There are two categories of values in JavaScript; they are Primitive Value, Objects and Functions.

Primitive Values are number, string, undefined, etc.

Primitive Value

Primitive Values are number, string, undefined null, booleans, symbols, bigInts. We can’t manipulate Primitive Values by our code. We can only use them when we need them.

Non-Primitive Values

Non-Primitive values are objects and functions. We can easily see the difference in the browser console. The browser will display them differently from primitive values. We can manipulate Non-Primitive values by our code.

Expressions

Expressions are like a question, but not all types of questions. Expressions are the types of questions that JavaScript can answer. The expression always returns a single value.

Checking The type

We can easily check the data type of a JavaScript variable. To check the data type of a variable, we have to use a built-in function typeOf().

There is an interesting thing in there. It will work fine if we don’t use the parentheses. But sometimes it doesn’t work. We must use parentheses when trying to check a function type value unless it shows some errors.

No other type

There is no other type of values in JavaScript than primitive values and objects and functions. We can check on the browser console by using typeOf function. Someone can think the string is also an object. But it is not true. It is just an illusion.

--

--