Common JavaScript Interview Qs.

Tarequl Islam
5 min readMay 8, 2021

You have learned enough basic Javascript, that's why you searched for JS interview questions! right? Got yeah!

Javascript is lightweight language but there is tons of cubicle part to learn such as! oops, if I write such as, it will be like half an hour story about the cubicle.
So today we are gonna learn basic interview most asked frequently question and the solution.

What is Javascript?

javascript is a programming language which is lightweight, Its basically a client side and server side scripting language. Javascript includes all programming aspect like condition, iteration and more. Javascript building framework and libraries, JS also called OOP mean object oriented programming . with the help of javascript web pages will be dyanic and it can get better experience .

Javascript DataType?

DataType basically means what type of data can be used in programming. Javascript has actually six type of datatype as you know and they are divided by three categoris and which is Primitive , composite and special. String, Number, Bolean, Obejct, Array and values are in Primitive categoris.
function is in composite categories and last special has NaN, Undifined

Null VS Undefined||
First, with Bismillah we are gonna talk about What is Null vs Undefined?
This question is pretty much common in interviews.
Let's see the image first

null and undefined demo

if u got this, you got this.
Null is actually value with No Value! kinda confused? So look at the picture above again, Non zero value means there some values like strings and other objects.

0 means there is a number value. Null means there is a place for value but I didn't pass string or object and declared null means no value inside, and last undefined means that I didn't pass even value so how can you can this …
huuuuh! Relax and read twice slowly bro!

null == undefined // true
null === undefined //false

Double Equal and Tripe Equal

Wait wait, you think I wrote again null vs undefined. No buddy chill and listen,
Double equal mean the values are same they get are same and as a comparison, they behave similarly,
but when we force them to check strictly the same as value and “DataType”, now they are not the same as data. I make confusion again,
let me show you some code example :

const number = 1234 
const stringNumber = '1234'

console.log(number == stringNumber) //true
console.log(number === stringNumber) //false

if I check about value, they both are the same for == because they have 1234 as value but if we check === for data they are not the same.
1st one has “number 1234” and 2nd one have “String 1234”

Closure

closure function

Okay! now we are talking about closure, it's like Christopher Nolan’s movie “Inception”, where Leonardo makes the dream into a dream, I mean dream layer.
Here closure you can make a layer, not a dream but a function.
You can declare a function and can call another function into it

When you call the function or return the function they create a closed environment, when the inner function accesses the outer variables and calls it later with several time they will have own values as like they create their own environment

function outer() {   var b = 10;
function inner() {

var a = 20;
console.log(a+b);
}
return inner;
}

Bind, Call and Apply

if any object has a method and if try to put this method to another object which is called “call,apply and Bind”

Call: after calling first argument and if you want to apply that object then you have to pass parameter, hen you put parameter you have pass those parameter by coma ( , ) separation .

Apply: This is the same as call method but what you have to this time when yu try to pass parameter you have to just pass by an Arra [ ] separation.

Bind: If you call the method by loop I mean again and again if you call the same method this is called binding .

Remove duplicate Item

No one try the same meal at buffet, you need kind of varient .
so in javascript its a common case in many project you have to remove duplicate item .

The simple thing you can do easily which is,
First convert an array of duplicate to a set , then new set will remove duplicate item ,
Then convert the set to an array again…
pretty easy, right ?

unique = [...new Set(array)];

What is Reverse() method?

So, the reverse method reverses all the method in a array place, the first array element placed in a last and last element placed in a first positon and then join() method joins all the elements of array into a string.

Window Obejct

Javascript present window object to the global object in Browser. global variable are the properties of window object . There are many global variable here you can check the picture above.

--

--