Fundamentals of JavaScript
Understand fundamental JavaScript concepts such as variable declaration and initialization, data types like numbers, strings, and booleans, and how different operators function. This lesson helps you handle inputs and perform operations correctly by converting data types and applying operators essential for building clear and efficient code.
Types of data in programming
Several forms of data may be used in programming. Here’s an example:
let persons = 1;
let greet = "Hello!";
In the example above:
- The variable,
persons, stores a number. - The variable,
greet, stores a string.
Variable declaration
In JavaScript, we use let to declare a variable. Here’s an example:
let persons; // declaring a variable
Here, the variable persons is declared, but its value is undefined.
Note: It is a good practice to initialize every variable.
Variable initialization
Assigning a value to a variable at the time of its declaration is called ...