A closure is an inner function that has access to the variables and parameters of its outer function, even after the outer function has returned.
|SNo.||Var Keyword||Let Keyword|
|2||Var declarations can be globally or function scoped.||The Let keyword scope is limited to block scope|
|3||Var can be Redeclared||The Let can not Redeclared|
|4||Var can be updated||The Let can be updated|
|5||Hosting of Var means declarations of variales and function should be before execution of code. It is initialized as undefined||Hosting of Var means declarations of variales and function should be before execution of code. It is left as uninitialized|
The == operator compares the values of two variables, while the === operator compares both the values and the types of the variables.
We can also understand the flow of Bubbling event with the help of the below flow chart.
Synchronous programming is when each task is executed in order, one after the other, while asynchronous programming allows multiple tasks to be executed simultaneously.
For example, consider the following code:
console.log(x); // undefined
var x = 5;
In this code, the console.log statement will output undefined because the variable x is declared with the var keyword, which is hoisted to the top of the scope. However, the assignment x = 5 is not hoisted, so the value of x is undefined until it is assigned later in the code.
The main difference between a let and a var variable is that let has block scope, while var has function scope.
Event Capturing is also known as Event Trickling. Event Capturing is opposite to event bubbling, where in event capturing, an event moves from the outermost element to the target. In capturing, the event starts at the document object and then "captures" its way down to the target element.
We can also understand the flow of Capturing event with the help of the below flow chart.
A function declaration is a named function that is defined using the "function" keyword, while a function expression is an unnamed function that is defined using a variable assignment.
An IIFE (Immediately Invoked Function Expression) is a function that is executed immediately after it is defined.
"undefined" means that a variable has been declared but has not been assigned a value, while "null" is an explicit assignment of a non-value.
"null" is an explicit assignment of a non-value, while "undefined" means that a variable has been declared but has not been assigned a value.
"continue" is used to skip a single iteration of a loop, while "break" is used to exit a loop entirely.
A higher-order function is a function that takes other functions as arguments or returns functions as its result.
"var" can be redeclared in the same scope, while "let" cannot be redeclared in the same scope.
A constructor function is a function used to create objects, while a class is a template for creating objects.
A prototype is a property of a function that allows for the creation of new objects with the same properties and methods as the original object, while a constructor is a function used to create objects.
A callback function is a function that is passed as an argument to another function and is executed after an asynchronous operation has completed.
A pure function is a function that always returns the same output for the same input and has no side effects.
A prototype is a property of a function that allows for the creation of new objects with the same properties and methods as the original object.
Here, are some common methods for getting and setting attributes.