DEV Community

vidhya murali
vidhya murali

Posted on

Data Types in JavaScript

Data Types In Javascript

Data Type - A "data type" is an attribute that specifies the size, range, and type of values that a variable can store

The ECMAScript standard defines eight built-in data types in JavaScript. These are split into two categories: seven primitive types (immutable, single values) and one non-primitive type (mutable collections)

[ mutable values can be modified in place after creation, while immutable values cannot be altered once created ]

Examples :

The Concept of Data Types
In programming, data types is an important concept.

To be able to operate on variables, it is important to know something about the type.

Without data types, a computer cannot safely solve this:


Does it make any sense to add "Volvo" to sixteen? Will it produce an error or will it produce a result?

JavaScript will treat the example above as:


[ When adding a number and a string, JavaScript will treat the number as a string. ]

Top comments (0)