π§ Training β Basic Components
📚 70 questions⏱ 15-20 min🏆 Instant feedback
π§ Basic Components JavaScript
JavaScript
π― What You Will Learn in This Training
This interactive training will help you master JavaScript Components No :
- β Ali covering all
- β var, let, const
- β data types using
- β using No
- β (Scope) variables
- β definition using functions (Functions)
- β expression (Expressions)
- β Ability to retake the training to improve your level and reinforce concepts
- β string writing code better
ποΈ Basic Components JavaScript?
Basic Components JavaScript . , JavaScript Basic Components language execution .
- β variables (Variables): data
- β data types (Data Types): type
- β No (Operators):
- β functions (Functions): Restart using
- β (Scope): variables
- β expression (Expressions): Ali
π¦ variables (Variables) - data
variables data memory. type data variables using No No :
// definition variables
var name = "Ahmed"; // method ( )
let age = 25; // variables variable ( )
const PI = 3.14; // variables constant
// let const
age = 26; // β
( change value let)
// PI = 3.15; // β False! No change value conststring :const , let only change value.
π§© data types (Data Types)
JavaScript data :
- (Primitive Types):
- String - string
- Number -
- Boolean - (true/false)
- undefined -
- null - value
- Symbol -
- (Reference Types):
- Object - object
- Array -
- Function - functions
- Date -
// data types
let text = "Hello "; // String
let number = 42; // Number
let isActive = true; // Boolean
let person = { // Object
name: "Ahmed",
age: 25
};
let colors = [" ", " ", " "]; // Arrayβ No (Operators) -
No variables. :
- No calculation: +, -, *, /, %
- No comparison: ==, ===, !=, !==, >, <, >=, <=
- No: && ( ), || ( ), ! ( )
- No: =, +=, -=, *=, /=
- No condition: ? : (operator condition No )
// No
let x = 10 + 5; // 15 ( )
let y = 20 * 2; // 40 ( )
let isEqual = (5 == "5"); // true ( )
let isStrictEqual = (5 === "5"); // false ( )
let result = (10 >5) && (3< 7"); // true ( )
x += 5; // x = 20 (addition )
let message = (age >= 18) ? " " : " "; // operator conditionβοΈ functions (Functions) - code Restart No
functions code definition, code organization Restart using.
// definition functions
// 1. function definition
functiongreet(name) {
return"Hello " + name;
}
// 2. expression function (Function Expression)
const add = function(a, b) {
return a + b;
};
// 3. functions (Arrow Functions) - ES6+
const multiply = (a, b) => a * b;
// 4. functions (Anonymous Functions)
setTimeout(function() {
console.log(" execution 2 ");
}, 2000);
// call functions
console.log(greet("Ahmed")); // "Hello Ahmed"
console.log(add(5, 3)); // 8
console.log(multiply(4, 6)); // 24π (Scope) - variables
variable code. command errors.
- (Global Scope): variables
- (Function Scope): variables only function ( var)
- (Block Scope): variables only { } ( let const)
let globalVar = " "; //
functiontestScope() {
var functionVar = " "; //
console.log(globalVar); // β
console.log(functionVar); // β
if (true) {
let blockVar = " "; //
console.log(blockVar); // β
}
// console.log(blockVar); // β False! No
}
testScope();
// console.log(functionVar); // β False! No function