DEV Community

Cover image for Javascript: Data type and variables
Temitope Agbaje
Temitope Agbaje

Posted on

10 5

Javascript: Data type and variables

Data types are concepts to be able to operate on variables.
JavaScript variables can hold Data types like Strings, numbers, arrays, and so on.

Strings
Strings are written in double quotes(" ") or single quotes(' ').
Alt Text

In the image below..you can use a double quote and single quote interchangeably or when using two double quotes or a single quote in a sentence, a backslash can be used in front.
Alt Text

Number
For the number data type, It is either a negative or a positive number. It can also be a decimal number.
Alt Text

Booleans
In boolean, It is either true or false, Yes or no, off or on.
Alt Text

Arrays
It is used to store a list of data. Arrays are written using square brackets [ ].
Alt Text
An array can be written inside another array.Arrays can be accessed by their index. Every array has an index that starts with 0.

Alt Text

Objects
The object is a data type that allows the storage of collections of data. They are denoted using square brackets { }.
Alt Text

To access the data of an object: ObjectName.keyName
Alt Text

Undefined
If a variable has been declared but has not been assigned a value, has the value undefined.
Alt Text

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay