Here's a brief overview of important JavaScript concepts, along with sample code snippets for each:
1. Hoisting
Hoisting refers to JavaScript's behavior of moving declarations (variables and functions) to the top of their scope before code execution.
console.log(a); // undefined due to hoisting
var a = 5;
2. Single Threaded
JavaScript runs in a single thread, meaning it can only execute one task at a time.
3. Synchronous
Synchronous code is executed line by line, with each operation blocking the next one until it completes.
console.log("First");
console.log("Second");
4. Function Invocation
This is the process of calling or executing a function.
function greet() {
console.log("Hello");
}
greet(); // Function invocation
5. Variable Environment
The context in which variables are stored and accessed, typically inside a scope (global, function, or block).
