JavaScript, often abbreviated as JS, is a high-level programming language that is used to make interactive websites and web applications. It's one of the three core technologies of web content production, alongside HTML and CSS. Here we will explore some basic JavaScript code examples to help you understand its fundamentals.

JavaScript is a versatile language that can be used for a wide range of applications, from simple animations to complex algorithms. Before diving into the code examples, it's crucial to understand that JavaScript is case-sensitive, meaning it differentiates between uppercase and lowercase letters.

Basic JavaScript Syntax
To get started with JavaScript, you first need to understand its basic syntax. JavaScript uses statements, which are истреminals that perform an action. A JavaScript statement is an instruction that the browser can understand and execute.

Here's a simple JavaScript code example that outputs the text "Hello, World!" in the console:
console.log("Hello, World!");
Variables and Data Types

Variables are used to store data in JavaScript. They are declared using the 'var', 'let', or 'const' keywords, followed by the variable name and its value.
JavaScript is a dynamically typed language, which means you don't have to declare the type of a variable. Here's an example:
let name = "John Doe";
let age = 30;
let isStudent = false;
Operators

JavaScript uses operators to perform operations on variables and values. Some common operators include addition, subtraction, multiplication, division, and modulo.
Here's an example that uses the addition operator to add two numbers together:
let x = 10;
let y = 5;
let sum = x + y;
Control Structures

Control structures are used to control the flow of your JavaScript code. They are necessary to make decisions based on certain conditions and to repeat code a specific number of times.
Here's an example of an if-else statement, which is a common control structure in JavaScript:









let age = 20;
if (age >= 18) {
console.log("You can vote!");
} else {
console.log("Sorry, you can't vote yet.");
}
Loops
Loops are used to repeat code until a certain condition is met. JavaScript provides several types of loops, including for, while, and do-while loops.
Here's an example of a for loop that counts from 0 to 9:
for (let i = 0; i < 10; i++) {
console.log(i);
}
Functions
Functions in JavaScript are used to group code together and reuse it. They are defined using the 'function' keyword, followed by the function name and its parameters in parentheses.
Here's an example of a simple JavaScript function that greets the user:
function greet(name) {
console.log("Hello, " + name + "!");
}
JavaScript is a powerful and versatile language that offers endless possibilities for web development. With these basic JavaScript code examples, you have a solid foundation to build upon and explore more complex concepts. Happy coding!