Top 10 interview questions you should know

Pabel Yeatun
3 min readMay 8, 2021

most of the time this 10 questions will ask in the interview ,so i am discussing about this 10 questions

  1. double equal (==) vs triple equal (===)

for the double equal it will check only values but for the triple equal check values and also types.

here i will give an example that will helps you to understand clearly

1)const num1 = 24;

const num2 =”24"

if(num1 == =num2){

console.log(“the condition will be true”)}

else {

(“condition is false”)

//output is the condition will be true

2)const num1 = 24;

const num2 =”24"

if(num1 == num2){

console.log(“the condition will be true”)}

else {

(“condition is false”)

//output is condition is false

for example 1 and 2 we ca see the values is number and string for example one double equal are checking only values not types and triple equal checking values and types.

2)Scope, block scope, acc:

when you add function and declare the values in the function then you have to show the output only in the function other wise it will show error, but if i declare a value out of the function it be a global values that i console any where,

if i set the value with var then i can console any where but if i use let or const then i can only console in the function thats a block scope

var is so flexible so if i put console before the values then that will give undefined but not error,for the let and const it will show error

3)Closure:

if one function have another function that we do return that will be close environment and they have their own external variable

4)between bind, call and apply:

when in the function’s object have a method and that method i want to use in another method that time i can use call,apply or bind, for call if use another method have to pass after that have to pass parameter with comma but for the apply have to pass with array

5)Truthy and Falsy values:

basically its depend on the condition when condition is valid then that will be true other wise it will be false

example:

const age =50;

if(age>0){

console.log(‘true’)

}

else{(‘false’}

//output is true

6)Null Vs Undefined, different ways you will get undefined:

undefined:

when declare the variable but not set the value that time it will show undefined. if the function not set the return,if you have the variable but not set the value then it will show undefined

null:

when you have the value in that value are not set or want to set that time it will show null

7)window, global variable, global scope

An object that still resides on a global scale is a global object.

A global object is often specified in JavaScript. When scripts generate globalized variables with the var keyword in a web browser, they are generated as global object members. (This is not the case at Node.js.) The interface of a global object relies on the script running context

8)this keyword

This keyword is one of JavaScript’s most often used yet frustrating. What you know about this keyword is going to learn here.

A single object refers to this. Now, the object relies on how a function containing the keyword is named.

9)event loop stack and queue

A message queue, which is a list of messages to be processed, is used for the JavaScript runtime. Each message has a corresponding function that is named in order to process the message.

The runtime begins managing the messages on the queue at any point during the event cycle, beginning from the oldest. To do this, the message is deleted from the queue and its corresponding operation is invoked with the message as an input parameter. Calling a function generates a new stack frame for the function’s use, as it often does.

10)Remove duplicate item from an array

To begin, create a Set from an array of duplicates. Duplicate elements would be removed by default for the latest Set.
The collection could then be converted back to an array.

The indexOf() method returns the index of an element’s first appearance in an array.

If an element is in an array, include() returns true; otherwise, it returns false.

--

--