javascript theory - IliaKobalia/QA-program GitHub Wiki

JavaScript Theory

Variables

Variables are essential parts of any program. A variable is part of a code that stores a value of some data. It can be a simple number or string or some complex and nested structure. It can hold the result of a function or some computations. Variables can be used in the following parts of a code to easily access a value that was previously calculated/fetched in the program. To create a variable in JavaScript, keywords let and const can be used. Keyword let creates variable that can be reassigned. Variables created using const are immutable and called constants.

More info about variables can be found there

https://javascript.info/variables

https://www.javascripttutorial.net/javascript-variables/

Data Types

Variables store values of different data types. Primitive data types are the most basic types of data in JavaScript. A primitive holds a single, simple value rather than a collection or object. The main primitive types include number, string, boolean, null, undefined. There are other primitive types such as bignt and symbol and a complex type object, but we will focus on the most common primitive types for now. Each type represents a specific kind of value, such as a number (42), a piece of text ("hello"), or a true/false value (true). Understanding these types is crucial, as they are used throughout all parts of a program, from storing user input to controlling logic flow.

Number

String

Boolean

Null

Undefined

More info about variables can be found there

https://javascript.info/types

https://www.javascripttutorial.net/javascript-data-types/

Type Convertions

Conditions

Conditions are used in JavaScript to make decisions in your code. They allow the program to run different pieces of code based on whether a certain condition is true or false. The most common way to write conditions is using if, else if, and else statements.

A condition usually checks something using comparison operators (like ===, >, <, etc.). If the condition is true, the code inside the block runs. Otherwise, the program can skip it or run an alternative block.

Example:

let score = 80;

if (score >= 90) {
  console.log("Excellent!");
} else if (score >= 70) {
  console.log("Good job!");
} else {
  console.log("Keep trying!");
}

Conditions help control how your program behaves in different situations — such as validating user input, handling errors, or customizing the user experience.

Links:

https://javascript.info/ifelse

Loops

Functions

Arrays

Objects