Basic Interview Preparation for Beginners On JavaScript for Web Development Job

Dev. Hossain
3 min readMay 11, 2021

Truthy and Falsy Values in JavaScript

· Any number is truthy other than 0 zero.

· Any string is truthy other than an empty string.

· Empty array [], empty object {} is truthy.

· Anything undefined in falsy.

· Anything null is falsy.

· Anything NaN is falsy.

Null Vs Undefined in JavaScript

If you do not ‘’return’’ any variable in the function then the value will be undefined. Or if you write the ‘’return’’ keyword in the function but do not set any variable then the result will also be undefined.

And if you do not set any parameter then the result will also be undefined.

On the other hand null means, the value does not exist. When we set any variable = null that means we are not storing anything on that variable and it is a null variable.

Double equal == vs Triple equal === in JavaScript

Double equal has only checked the value of two variables not the type of the variables. On the other hand triple equal checks both the value and the type of variables.

Difference Between Bind, Call and Apply in JavaScript

Suppose you have a method in an object. If you want to use this method anywhere, you can use the call, apply, and bind method of JavaScript.

If you use the call method, first you have to declare the argument of the object that you want to access then you have to use parameters separating them with comma.

Similarly, the apply method also does the same thing but the difference is, you have to use the parameter inside the array.

On the other hand, if you want to use a method many times you can use the bind method. Using the bind method you can make a new object and use it as many times as you want.

What is Window and Global Variable in JavaScript

The window is a JavaScript runtime environment. Any variable that is located outside the function is called a global variable.

But the exception is when you forget to use a variable keyword before a value then the value is treated by javascript a global variable.

What is JavaScript ‘this’ Keyword

When you execute a function and there is nothing before this execution then it will be treated by javascript as a window function.

On the other hand, if there is something before function then it will be executed with javascript ‘this’ context.

Asynchronous JavaScript setTimeout and setInterval

Javascript setTimeout method works asynchronously. Asynchronously means it does not execute synchronously.

It takes time and waits for execution until the stack over. On the other hand, the setInterval is executed continuously in a specific time that is set for it.

How JavaScript Event Loop Works

Javascript has an event loop. This event loop maintains a queue of the execution and it creates a set stack for every execution of the queue and starts working from the top of the stack.

When all the works of stack finish then it takes other queues asynchronously. In this way, the javascript event loop works.

--

--

Dev. Hossain
0 Followers

An enthusiastic programming language learner. Love to live with coding. Travelling is the addiction. Nature is my mate.