JavaScript Interview Questions & Answers

CodeyMaze
2 min readApr 8, 2022

--

Q1. What would be the result of 2+5+”3” ?

2 & 5 are integers so they will be added => 7. 3 is a string and hence will be concatenated. So the result will be 73.

Q2. What is IIFE ?

IIFE are immediately invoked function expressions. That means it executes immediately after its created.

(function iife_func() {console.log(‘Printed immediately’); }) ()

Q3. What is the difference between undeclared and undefined?

Undefined means variable has been declared and has not been assigned any value. Whereas undeclared variables are those which are not even declared in the program.

Q4. console.log(typeof []) ?

Object

Q5. What is callback?

Callback is a function that is passed to another function as a argument and can be called later by that function.

Q6. What is the difference between foreach and map?

The main difference between foreach and map is that map returns a new array by applying callback function on each element of the array while the foreach method does not return anything.

Q7. Why use arrow functions?

The main use of arrow function is no binding of ‘this’.

In regular functions, this keyword is bound to different values based on the context in which it is called.

In arrow functions, this is lexically bound that means it use this from the code which contains this arrow function, no matter from which context it is called.

Q8. What is the difference between isNaN and Number.isNaN?

The function isNaN converts the argument to a number and return true if the resulting value is NaN.

The function Number.isNaN does not convert the argument and return true if the argument type is number and value is NaN.

Q9. What is null in javascript?

Null in javascript means the absence of any value.

Q10. What is the difference between for..in and for..of?

For…in iterates over keys of an object and then we have to use obj[key] to access the value whereas for…of iterates over object values.

You can watch the video for this here : JavaScript Interview Questions

--

--

CodeyMaze
CodeyMaze

Written by CodeyMaze

Crafting Solutions Through Code & Words https://codeymaze.com Feel free to follow me :)

No responses yet