Discuss the scope of var, let, and const

JavaScript has three different variable declarations: var, let, and const. Each has its own scope, which determines where the variable can be accessed within your code.


var:

Function scope: Variables declared with var are scoped to the function they are declared in. They can be accessed anywhere within that function, including nested functions.

Global scope: If declared outside of a function, var variables are considered global and can be accessed from anywhere in the script.


let and const:

Block scope: Variables declared with let and const have block scope. This means they are only accessible within the block (e.g., if statement, for loop, function) where they are declared.

Tell us the use cases of null and undefined

Null and undefined are two special values in JavaScript that represent the absence of a value. They are often used to indicate different scenarios:


Null:

Explicit Absence: When you intentionally want to represent the absence of a value.

Default Value: Used as a default value for variables or properties.

Return Value: Functions can return null to indicate that a value was not found or that an operation was unsuccessful.


Undefined:

Implicit Absence: When a variable is declared but not assigned a value.

Missing Property: When you try to access a property of an object that doesn't exist.

What do you mean by REST API?

A REST API(Representational State Transfer Application Programming Interface) is a type of web service that allows communication between clients (such as web browsers or mobile apps) and servers using the principles of REST architecture. REST is a set of architectural principles used to design networked applications.