Frequently asked questions JavaScript interview

Motiullah Sajit
3 min readMay 8, 2021

--

Explain Truthy and Falsy values

In JavaScript, a truthy value is a value that is considered true when encountered in a Boolean context. All values are truthy unless they are defined as falsy. Falsy values are false, 0, -0, 0n, “ ”, null, undefined, and NaN. Without these values all the other values are truthy.

Difference between double equal (==) and triple equal (===)

These are both comparison equality operators, the triple equals are called a strict equality operator and the double equals are an equality operator.
Triple equals check both the value and the type of the operands, If both match then it's true. Double equals only check the value of the operands.

What is Closure?

Closure is the combination of a function bundled together with references to its surrounding state. closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created.

Difference between bind, call, and apply

Call: call() method invokes a function with a given ‘this’ value and arguments provided one by one.
Apply: Invokes the function and allows you to pass in arguments as an array.
Bind: returns a new function, allowing you to pass in an array and any number of arguments.

What is a Global variable?

The scope of JavaScript variables is either global or local. Global variables are declared outside the function and their value is accessible and changeable throughout the program.

Explain this keyword

The JavaScript this keyword refers to the object it belongs to. … In a function, this refers to the global object. In a function, in strict mode, this is undefined. In an event, this refers to the element that received the event.

Explain Event bubble

Event bubbling is that term relates to the order in which event handlers are called when one element is nested inside a second element, and both elements have registered a listener for the same event.

How does recursion work?

Recursion in programming means calling a function within itself until a certain condition is reached. In JavaScript, since functions are pass by reference, the function can be passed to itself as one of the arguments, and then called within the body of the function.

What is DOM?

The Document Object Model (DOM) is a programming interface for HTML documents. It represents the page so that programs can change the document structure, style, and content. The DOM is an object-oriented representation of the web page, which can be modified with a scripting language such as JavaScript.

What is POST Method?

POST requests are used to send data to the API server to create or update a resource. The data sent to the server is stored in the request body of the HTTP request.

What is API?

API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other.

Explain Let and Const

const is a signal that the identifier won’t be reassigned. let is a signal that the variable may be reassigned, such as a counter in a loop, or a value swap in an algorithm. It also signals that the variable will be used only in the block it’s defined in, which is not always the entire containing function.

--

--