Menu

Post image 1
Post image 2
1 / 2
0

Javascript syntax explanation

DEV Community·sai sanjana·17 days ago
#vX64jfSZ
Reading 0:00
15s threshold

sai sanjana

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.

Read More