javascript interview questions
Tech Interview

JavaScript Interview Questions


If you’re planning to attend the Front End developer interview, then you must know about JavaScript. Here are the most important and probably asked JavaScript interview questions.

1. Explain JavaScript?

JavaScript is a scripting language used in both client side and server side scripting. It is also an object oriented programming language that allows you to build static HTML pages.

2. List the JavaScript types?

  • Boolean
  • Function
  • Null
  • Objects
  • String
  • Number
  • Undefined

3. How to create an object in JavaScript?

Object in Javascript can be created in three ways

  • By using Object literal
  • By creating instance of object
  • By using object constructor

4. What is negative infinity?

A number derived by dividing negative numbers by zero in JavaScript gives negative infinity.

5. Write a code to create an array in JavaScript?

Array can be created in three ways in JavaScript

  • By  using array literal
  • By using an Array constructor
  • By creating instance of Array

6. What is DOM?

Document Object Model-DOM. DOM represent the html document and it is used to access and change the content of the HTML.

7. What will be the output of the given code?


Here delete operator deletes the properties from an object. But X here is a local variable. so delete property does not affect local variable.

8. List all types of pop up boxes available in JavaScript?

  • Confirm
  • Prompt
  • Alert

9. Explain break and continue statement?

Break statement exits from the current loop and continue statement continues with the next statement of the loop.

10. Write the output of following code?

11. What is” == “operator?

When two operators are having the same value without any type conversion “==” operators return True. It is also called as a strict equality operator.

12. List the looping structures in JavaScript?

  • While
  • do-while loops
  • For

13. List all the keywords used to handle exceptions?


Catch and

finally is used to handle exceptions

14. What are the screen objects in JavaScript?

It is used to read the information from the client side

  • AvailWidth
  • AvailHeight
  • ColorDepth
  • Height
  • Width

15. write syntax to create function in JavaScript?

To create Function in JavaScript

16. What are two data types in JavaScript?

  • Primitive Data Types
  • Non-primitive Data Types

javascript interview questions

17. Write a code to get the total number of arguments passed to a function?

By using arguments.length property we can get the total number of arguments passed to a function.

18. What is a closure?

It is created whenever a variable is accessed which is defined outside the current scope is accessed from within the some inner scope.

19. List some advantages of using JavaScript?

  • Speed
  • Server Load
  • Versatility
  • simple Implementation

20. Write a Hello world example of JavaScript?

21. How to use external JavaScript files?

External JavaScript can be used to embed all the JavaScript files into a single file. JavaScript.

22. Is JavaScript is a case sensitive language?

Yes, JavaScript is a case sensitive language.

23. What is a use of history object?

History object is used to switch to history page such as forward and back from the current page or another page in a browser. The three types of history objects are

  • history.forward()
  • history.back()
  • history.go(number): number may be “+”for forward, “-“ for backward.

24. List the valid scopes of the variable?

  • Global Variables- It is visible everywhere in the  JavaScript code.
  • Local Variables- It is visible only within the function.
READ  ASP.NET Interview Questions

25. How to get the reference of a caller function inside a function?

The arguments have a callee property, which makes you the reference to the function you’re inside of .