Common JavaScript Question

There are some common interview questions.

Prodip Munshi
2 min readMay 8, 2021

Var vs Let vs Const —

var is a functional scoped variable and it’s re- declarable and re-assignable. if you assign a value without declaring the variable it should be var.

let is a block-scoped variable and it isn’t re- declarable but re-assignable. if you declare a variable with let in a block you can't access that variable outside the block.

const is also a block-scoped variable and it isn’t re- declarable and not re-assignable.

Null vs Undefined —

When we declare a variable and do not assign a value it is “undefined”. But when we declare a variable and want to keep blank but not “undefined” we use “null”.

Closure —

A function that is in a lexical scope and uses the resource from its lexical scope. But when we use that function outside the lexical scope we are also able to access all resources used that function from its own lexical scope. That case where that data stored is called closure.

“==” vs “===” —

“==” only check the values are is equal, but “===” check the values are equal and same data type. “===” also check the reference, if two are the same value and same data type but not the same reference it should be false.

DOM —

The full form of DOM is “Document object model”. When the browser receives an HTTP response from the server it is displayed in the browser. behind the seen browser provide us a web API of response who are tree-structured data model that's called DOM.

What is an API —

API is short for Application Programming Interface, and it basically connects two applications.

The Purpose of API —

An API is a way for other programs to interact with a program without the developer having to share the program’s entire code. Basically, we send and some HTTP requests to the backend server and receive responses from the server.

Hoisting —

Hoisting is JavaScript’s default behavior of moving declarations to the top. If we assign a value to a variable and declare the variable after assign it should no error.

This —

this keyword is the reference of the owner object where the method is.

JSON —

JSON stands for JavaScript Object Notation. JSON is a format for storing and transporting data. JSON is often used when data is sent from a server to a web page.

“use strict” —

The purpose of "use strict" is to indicate that the code should be executed in "strict mode". With strict mode, you can not, for example, use undeclared variables.

--

--