Java Script Interview Question

 Q) what is "this" keyword in javascript?

Ans - this refer to the object of the immediate parent

Q)  what is hoisting?

Ans - moving all the declaration to the top flow

console.log(a)

let a = 10;

after hoisting :

let a = 10

consolge.log(a)

Q)  Difference b/w let, var and const?

Let and const is the ES6 feature.

Var - global scope

const - cannot reassign a variable

 - block scope 

let - it has a block scope

    - can be reassigned

Q)  Talk about the arrow function? 


Q ) Before the arrival of the arrow function, we where using bind method in regular function, the why we stopped using bind method?

Ans - arrow function inbuilt knows who the parent is, meaning this for the arrow function is automatically bind to the object.

But in normal function, we have to bind it to the class to know which object it is used.

Else this can be bind to the window, object or anything else

Q) What is a closure? 

Ans - Inner function can access the outer function variables 

Q) Difference between for loop and map() ?

for () -  it returns the same array

map() -  it returns the new array , and length of the actually array should be the same of return array

Q) Difference between HTML and html5

Q) Diff between normal function and fat arrow function

Q) What is lexical scoping in javascript

Q) What is closure in javascript.

Q) Different between == and === in javascript

Q) Make second p tag change color on hover using css

<div>

    <p></p>    

    <p></p>    

    <p></p>    

</div>

Q) Make all p tags bold and change color to blue on click of button using JS/Jquery

<div>

    <p></p>    

    <p></p>    

    <p></p>    

</div>


Q) Given an array print all the items in an OL/UL list

 const a = [{name: "Apple", id: 1}, {name: "Apple2", id: 2}, {name: "Orange", id: 3}, {name: "Berry", id: 4}, {name: "Fruit", id: 5}]


Q) Explain the higher-order function

Q) explain 'this' keyword

Q) explain 'hoisting' in javascript

Q) What are the call back function

Q) What is template literal

 Q) what is object prototype

Q) Explain the bind() method in javascript

Q) What is dom element. Explain with example

Q) What is rest parameter and spread operator

Q) What is object restructuring

Q) What is use of promise in java scritp

 Q) How to fetch an API in java script.

 Q) Map() vs forEach()

Q) reduce() in java script

 Q) Coercion in java script

eg1 - 3 + "3" 

eg2 -  3 - "3"


 truthy - 

All values except 0, 0n, -0, “”, null, undefined and NaN are truthy values.

Q) is javascript a statically typed or a dynamically typed language?

 Q) Event loop in java script

 Q) what is synchronous and asynchronous in java script


0 Comments