Some Interview questions of JavaScript

Muhammad Ahasanur Rahman
2 min readMay 10, 2021

I have been taking preparation for facing JavaScript interview. I have summarized some answers which may be helpful to you for your interview.

  1. There are two data types in js. Primitive and Non-primitive data type. At first see primitive types:

We use non-primitive types to store many values. Now see Non-primitive types:

2. There is popular question about comparison operators differences (== , ===). (=) sign is used to assign. Run the code

3. Logical operators ( || , && ) don’t return true or false. In (||) operator if first value is truthy then it is returned else always second value is returned. In (&&) operator if first value is falsy then it is returned otherwise always second value is returned.

4. NaN property indicates a value which is not a number (return true).

5. The “this” keyword refers to the object of which this is a property of. To understand, just find one step before of using “this” keyword. See the code to understand better.

6. A function that operates on other functions is called a higher order function.

7. JavaScript call() method can invoke(call) a method by specifying

the owner object.

apply() method takes arguments as an array.

bind() method returns a new function binding owner object

8. The closure is an ability of functions to remember variables and functions which are declared in its outer scope. There is a popular example to describe this concept. Let’s see

In line 11 in variable info information function is already stored. After calling info() we are getting value of person object. Here closure works. when information() is executed it sees returning function is using value of person(line 2) object. So it doesn’t destroy person object instead store its value in memory for further use. That is the reason we can enter values of it after execution of the information() function.

9. JavaScript is a dynamic typed language. During run time the type of variable is checked and can be assigned any type of value to that variable. See the code to better understand. In a static typed language we can’t do this

There are three scope in javascript. They are a. local, b. global, c. functional.

To better understand try to print the commented console.log() output.

There are so many features es6 , javascript have which are very important and can be asked in interview. Just google it and comment me if you face any problem with above examples. Happy coding.

--

--