A variable declaration is simply telling the computer that a variable exists and what value it should start with. Similar to other programming languages JavaScript also allows for the declaration of variables. There are three keywords in JavaScript that can be used to declare variables: let, var, and const. Each keyword has different rules and implications for how the variables they create can be


1. let: The let keyword declares a block-scoped local variable, optionally initializing it to a value. Block-scoped means that the variable is only available within the block it was declared in, which is usually denoted by curly braces {}.


2. var: The var keyword declares a function-scoped or global variable, optionally initializing it to a value. Function-scoped means that the variable is only available within the function it was declared in. Global variables are available throughout your entire code.


3. const: The const keyword declares a block-scoped, immutable constant variable, i.e. a variable that can not be reassigned. Constants are also called “immutable variables”, but that is a bit of a misnomer since they are actually variables just ones that cant be reassigned.

The map() method

The map() method loops through each element in array and calls the provided function for each element. This method creates a new array and doesnt alter the original array.

The filter() method

The filter() method in JavaScript creates a new array with the elements that satisfies the provided condition. This method calls a provided function for each element in array and verifies the condition given in the provided function and passes only those elements that satisfy the given condition.

The forEach() method

forEach() is used to execute the same code on every element in an array but does not change the array and it returns undefined.

Regular function

Inside of a regular JavaScript function, this value (aka the execution context) is dynamic. The dynamic context means that the value of this depends on how the function is invoked. In JavaScript, there are 4 ways you can invoke a regular function. During a simple invocation the value of this equals to the global object (or undefined if the function runs in strict mode):

Arrow function

The behavior of this inside of an arrow function differs considerably from the regular function's this behavior. The arrow function doesn't define its own execution context. No matter how or where being executed, this value inside of an arrow function always equals this value from the outer function. In other words, the arrow function resolves this lexically.