JavaScript is a dynamic programming language that allows the creation of interactive and complex content on websites. When we talk about data types in JavaScript, we are referring to the different types of values ​​that a variable can have. Data types are fundamental to understanding how information is stored and manipulated in JavaScript.

Variables

A variable is a container for storing data. In JavaScript, we declare variables using the keywords 'var', 'let' and 'const'. For example, let name = 'John';. Here 'name' is the variable and 'John' is the value we are storing in it.

Data Types

JavaScript has six primitive data types: String, Number, Boolean, Null, Undefined, and Symbol. Additionally, it has a non-primitive data type: Object.

String

A string is a sequence of characters used to represent text. In JavaScript, strings are wrapped in single or double quotes. For example, let name = 'John'; or let name = "John";.

Number

The Number data type is used to represent positive or negative numbers with or without decimals. For example, let age = 25; or let average = 19.5;.

Boolean

The Boolean data type has only two values: true or false. This data type is commonly used for conditional testing. For example, let isAdult = true;.

Null

Null is a special data type that represents "nothing" or "empty". For example, let empty = null;.

Undefined

A variable that has been declared but has not had a value assigned is of type undefined. For example, let test; Here, test is undefined.

Symbol

Symbol is a data type introduced in ES6 that produces a unique value that cannot be changed. For example, let sym1 = Symbol('sym');.

Object

Objects are used to store collections of data and more complex entities. They are different from primitive data types because they can contain multiple values ​​in the form of properties. For example, let car = {make: 'Toyota', model: 'Corolla', year: 2005};.

Operators

Operators are used to perform operations between variables and values. The main types of operators in JavaScript are: arithmetic operators, assignment operators, comparison operators, logical operators and bitwise operators.

Arithmetic Operators

Arithmetic operators are used to perform mathematical operations. For example, let sum = 10 + 20;.

Assignment Operators

Assignment operators are used to assign values ​​to variables. For example, let x = 10;.

Comparison Operators

Comparison operators are used to compare two values. For example, let result = (10 == 20); Here, result will be false.

Logical Operators

Logical operators are used to determine the logic between variables or values. For example, let result = (10 < 20 && 20 > 30); Here, result will be false.

Understanding variables, data types and operators is fundamental for anyone who wants to become a front-end developer. They are the foundation of any JavaScript program and are used in almost every script you will write.

Now answer the exercise about the content:

What are the six primitive data types in JavaScript?

You are right! Congratulations, now go to the next page

You missed! Try again.

Article image Introduction to Javascript: variables, data types, operators: Operators in Javascript

Next page of the Free Ebook:

69Introduction to Javascript: variables, data types, operators: Operators in Javascript

3 minutes

Obtenez votre certificat pour ce cours gratuitement ! en téléchargeant lapplication Cursa et en lisant lebook qui sy trouve. Disponible sur Google Play ou App Store !

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text