What are the different data types in JavaScript?
8 of them : String, number, boolean, BigInt, un defined, null, symbol and object
Explain hoisting in JavaScript.
Hoisting is the default behaviour of javascript where all the variable and function declarations are moved on top.
This means that irrespective of where the variables and functions are declared, they are moved on top of the scope. The scope can be both local and global.
To avoid hoisting, you can run javascript in strict mode by using “use strict” on top of the code:
Difference between “ == “ and “ === “ operators.
Both are comparison operators.
“==” is used to compare values, “ === “ is used to compare both values and types.
What is NaN property in JavaScript?
NaN property represents the “Not-a-Number” value. It indicates a value that is not a legal number.
What is the difference between ‘undefined’ and ‘null’ in JavaScript?
undefined means a variable has been declared but has not yet been assigned a value.
null is an assignment value. It can be assigned to a variable as a representation of no value :
How would you handle errors in JavaScript?
Errors in JavaScript can be handled using try-catch blocks, where code that may throw an error is placed within the try block, and the catch block handles the error if it occurs.
How does asynchronous programming work in JavaScript? Explain callbacks or Promises.
Asynchronous programming in JavaScript allows tasks to run in the background. Callbacks and Promises are two ways to handle asynchronous code. Callbacks are functions passed as arguments and executed when the task is complete. Promises represent the eventual completion or failure of an asynchronous operation, providing a structured approach to handle it.
What is a closure in JavaScript?
What is event delegation in JavaScript?
Event delegation is a technique in JavaScript where instead of attaching event listeners to individual elements, you attach a single event listener to a parent element. The events are then handled when they bubble up from the child elements. This approach is useful for dynamically created elements or when dealing with a large number of elements.
What are the higher order functions in JavaScript?
What is the difference between let, const, and var in JavaScript?
What is the difference between synchronous and asynchronous programming in JavaScript?
What is JavaScript?
What is the event loop in JavaScript?