Sign in

10 tricky interview question for js developer.

  1. What is Java Script ?

JavaScript is light-weight ,single threaded, interpreted or just in time programming language .

2.What are the features of JS?

The features of java script are dynamic typing , DOM manipulation , platform independent , functional style , prototype base , OOP support , async processing ,handling date and time , case sensitive format, handling event and light weight .

3.What is truthy and falsy values?

Truthy Value :string is true other than empty string (“”) , any number is true other than 0 .

Falsy Value : Undefined , null , 0 , NaN ,empty string (“”), false.

4. Null vs Undefined .

Null : Null means not existing or empty .

Undefined : Undefined means variable has been declared but value has not been assigned or initialized.

5. Difference between double equal (==)and triple equal(===)?

Here triple equal operator is strict equality operator because it compare value and type of value , while double equal operator is just equality operator .

6. What is function scope ?

Function scope : Variable declared inside the function is called function scope . Look at example below , a total variable only will be accessible within the function but can not access from outside.

7.What is block scope in js ?

Block Scope : Variable with var keyword can not be block scope . If a variable declared with using let and const keyword inside curly braces then it’s called block scope . This variable can not be access from outside.

8.What is closure ?

As per the closure definition, if inner function access the variables of outer function then only it is called closure.

OR,

If a function returns a function or if inside a function got a function then it creates a closed environment, Means it can access the variable from parent scope. This is called closure.

9. What is bind method?

In JavaScript function binding can happens through Bind() method. Using bind method , you can bind an object to a function. so that the function gives different result when its need. Otherwise , It will shows error.

10. What is DOM?

DOM stands for document object model. This is platform and language neutral interface which allows the programs or scripts to dynamically modify the or update the style ,content and structure of documents.

11.Typeof operator: ‘ Typeof’ is an operator used to return a string description of the type of a variable.

12.Callback function : Functions that are used as an argument to another function are called callback functions. Callback is a function that will be executed after another function gets executed.

13.What is function : Function is a block of which which perform a particular task.

14.The rest parameter (…) allows a function to treat an indefinite number of arguments as an array

15. Default parameter :This allows us to give default values to function parameters.

16.The Difference Between Arrays and Objects

In JavaScript, arrays use numbered indexes.

In JavaScript, objects use named indexes.

Arrays are a special type of objects, with numbered indexes.

17. What is map ?

The map() method creates a new array with the results of calling a function for every array element.

The map() method calls the provided function once for each element in an array, in order.

18. map vs forEach ?

map returns a new array.

forEach has no return value.

That’s the heart of the difference. Most of the other answers here say effectively that, but in a much more convoluted way.

Why should you use map rather than forEach ?

  • Just about anything you can do with forEach() you can do with map(), and vise versa.
  • map() allocates memory and stores return values. forEach() throws away return values and always returns undefined.
  • forEach() will allow a callback function to mutate the current array. map() will instead return a new array.

19.setTimeout(function, milliseconds ) Executes a function, after waiting a specified number of millisecond.

20.Scope determines the accessibility (visibility) of variables.

21.Difference between find and filter

  1. filter() method search through all the elements. return an array
  2. find() method search through all the child elements only. return an object

22.In JavaScript what is an argument object?

The variables of JavaScript represent the arguments that are passed to a function.

23.What’s the difference between event.preventDefault() and event.stopPropagation() methods in JavaScript?

In JavaScript, the event.preventDefault() method is used to prevent the default behavior of an element.

For example: If you use it in a form element, it prevents it from submitting. If used in an anchor element, it prevents it from navigating. If used in a contextmenu, it prevents it from showing or displaying.

On the other hand, the event.stopPropagation() method is used to stop the propagation of an event or stop the event from occurring in the bubbling or capturing phase.

24.What is negative infinity?

Negative Infinity is a number which is result of dividing a negative number by zero.

or

Negative Infinity is a number in JavaScript which can be derived by dividing the negative number by zero.

25.Function with default parameters :In java script default function parameters allowed named parameters to be initialized with default value if parameter value is missing . So it’s better to pass default value .