JavaScript basic syntax

Contents
Syntax basics
Variables
Data types
Strings

Syntax basics

JavaScript syntax is the set of rules, conventions, and grammar for writing JavaScript code. A JavaScript program consists of a sequence of statements, which are executed one by one.

let name = "JavaScript";

let price = 10 + 5;

Variables

Variables let you store values by giving them a name. You can use var, let, or const to declare a variable.let and const are block-scoped, while var is function-scoped.

let score = 10;

const PI = 3.14;

Data types

JavaScript has dynamic types. A value's type is determined at runtime. The main types are: number, string, boolean, null, undefined, object, and symbol.

let type = typeof "hello";

console.log(type);

Strings

Strings are sequences of characters, stored as primitives. You can use single quotes, double quotes, or template literals (backticks) with embedded expressions.

let first = "Hello";

let greeting = `Hello, ${name}`;

Next: Variables and data types

Article author: Arthur Isaev

Related articles
JavaScript
JavaScript course: 100 lessons from basics to advanced
What is JavaScript and where it runs
JavaScript basic syntax
Variables and data types
Operators and expressions
Conditional statements
Loops and iteration
Functions and scope
Objects and prototypes
Arrays and methods
Strings and template literals
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: