Top 10 JavaScript Interview Questions and Answers

1. What is Truthy and Falsie Value in JavaScript?

Every integer is true, except 0 (zero), and Every string are true except empty string. Also every undefined variable should be false. Please have look below example.

2. What is the difference between null and undefined?

undefined means when declarer variable but if we don’t assign anything in the variable, then it will show undefined. another example is when we call a function then if we don’t return it then it will show undefined. undefined is a negative value or false value.

null means empty or nothing, not exist anything. We use null for checking whether there exist anything or not. Also there was anything and we collect from there and its empty for checking it we use null

3. double equal (==) vs triple equal (===), what is the difference in it?

double equal operator ‘==’ only check the value of a variable, don’t check it’s type, but triple equal operator ‘===’ check both of its type and value of a variable

4. What is scope or block scope? What is hoisting?

In modern JavaScript ‘let’ and ‘const’ is a scope variable, when we declare a variable on the scope of curly brace {} it works only in it, but when we declare it outside curly brace it is global variable and we can use it every where in JavaScript

In the above code we decarded variable at last of all code, but JavaScript it brings to the first and it is called hoisting.

So, we can apply Hoisting only in normal JavaScript.

5. What is Closure, encapsulation?

When we call a function, was created inside of this function, then it created a closure environment of this function. If we call it using different variable it shows same continues value of its different variable. That means for different variable it creates same environment.

6. How internet works, DNS server, hosting server, database

Interner works through IP address. When we call anyone with the phone, we just select the person name and dial call, but this name has a uniqe number we have saved previous, the call is going through by this number in the internet this is called IP address. IP means Internet Protocol. This is similar to a phone number. Every website has a unique IP address.

Server is a lots of computer without Monitor, In this pc all data is stored as like a shelf.

7. What is an API, what is the purpose of API?

API means Application Programing Interface, We can explain API by giving an example,

If we want to browse Facebook and see our post. We don’t able enter on Facebook directly. First we need to give our ID and password then Facebook check whether is this a valid user or not. If our id and password matched then Facebook allow us to enter in the Facebook and Facebook show our post and status. In a summary of process of giving id, password and matching and then show our post and status Process is called API.

The purpose of API is to Load data from the server.

8. What is HTTP request, Status code?

When we go to a restaurant and find our favorite to eat. We don’t know whether our favorite food have or not. In the website same thing happened. When we call for data we call in a promise, that response ok or not ok, that means we can get data or not this is called HTTP request.

In our browser in network tab different code is shown, when we get data it shows 200 (means ‘OK’); If our url is wrong then shows 404 (‘Not Found’) these code are the status code.

9. Difference between GET and POST

10. Difference between bind, call and apply

There is a method (or function) in an object. If we want to use this by borrowing it one place to another place we can use call, apply, bind method.

Call — It first call the previous method of the previous object then it passes argument on which it will be applied and then it passes the parameter as comma (,) separation.

Apply— It first call the previous method of the previous object then it passes argument on which it will be applied and then it passes the parameter as an array.

Bind— It first call the previous method of the previous object and it bind new object on this previous method and then it call how much its needed.

Hello, I am Mehadi Hasan, Frontend React web Developer. From my little knowledge about JavaScript I am trying to publish somethings.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store