- What is JavaScript?
JavaScript is a high-level, dynamic, and interpreted programming language. It is a scripting language used for creating interactive and dynamic web pages and applications.
- What are the data types in JavaScript?
The data types in JavaScript are: Number, String, Boolean, Null, Undefined, Object, and Symbol.
- What is hoisting in JavaScript?
Hoisting is a JavaScript mechanism where variable and function declarations are moved to the top of the code. This means that declarations can be used before they are defined in the code.
- What is the difference between let and var in JavaScript?
The main difference between let and var is scope. Variables declared with var have function scope, while variables declared with let have block scope.
- What is closure in JavaScript?
A closure is a function that remembers its outer variables and can access them even after the outer function has returned.
- What is the difference between null and undefined in JavaScript?
Null is a value that represents the absence of a value, while undefined means that a variable has been declared but has not been assigned a value.
- What is the difference between == and === in JavaScript?
The double equal sign (==) performs type coercion, meaning it will try to convert the values to the same type before comparing them. The triple equal sign (===) does not perform type coercion and only returns true if the values are the same type and value.
- What is the difference between let and const in JavaScript?
The main difference between let and const is that variables declared with const are read-only and cannot be reassigned, while variables declared with let can be reassigned.
- What is the difference between function declaration and function expression in JavaScript?
A function declaration is declared as a statement, while a function expression is declared as part of a larger expression syntax. Function declarations are hoisted, while function expressions are not.
- What is a callback function in JavaScript?
A callback function is a function that is passed as an argument to another function and is executed after a certain event or operation has completed. Callback functions are used to handle asynchronous operations.