DEV Community

sai sanjana
sai sanjana

Posted on

Javascript syntax explanation

Hi all,
What is Syntax?
In simple terms, syntax is the set of rules that tells us how to write code so the computer understands it.

--Variables and Constants
Variables: Used to store data. Declared with let or var.
Constants: Values that don’t change, declared with const.

--Data Types
JavaScript supports different types of data:

Numbers: let age = 25;

Strings: let city = "Chennai";

Booleans: let isActive = true;

--Operators
Operators let you perform actions:

Arithmetic: +, -, *, /

Comparison: ==, ===, >, <

Logical: &&, ||, !.

Control Structures
These help you decide what the program should do:

--If-Else:
if (age > 18) {
console.log("Adult");
} else {
console.log("Minor");
}

--Loops: Repeat tasks easily
for (let i = 0; i < 5; i++) {
console.log(i);
}

Hence syntax plays an important role in javascript programming.

Top comments (0)