Javascript Questions

Warm up for Javascript interview with most asked questions and answers for junior, mid, and senior roles.

Junior

What is NaN property in JavaScript?

Show Answer

NaN property is a property of the global object that is used to represent the Not-a-Number value.

Junior

What is the use of a Number object in JavaScript?

Show Answer

Number object is used to perform number operations.

Junior

What is the use of a Boolean object in JavaScript?

Show Answer

Boolean object is used to perform boolean operations.

Junior

What are the falsy values in JavaScript?

Show Answer

Falsy values are:

  • 0
  • ''
  • null
  • undefined
  • NaN
  • false
Junior

What are JavaScript Data Types?

Show Answer

JavaScript data types are the types of values that JavaScript can store.

 

There are seven data types in JavaScript:

  • Number
  • String
  • Boolean
  • Undefined
  • Null
  • Symbol
  • Object
Junior

What is the use of the Push method in JavaScript?

Show Answer

The push method is used to add an element to the end of an array.

Junior

What is the use of window object?

Show Answer

The window object is a global object that has the properties pertaining to the current DOM document

The document property of the window object has the DOM document and associated nodes and methods that we can use to manipulate the DOM nodes and listen to events for each node.

The window object is global, so it’s available in every part of the application.

Junior

What is JavaScript?

Show Answer

JavaScript is a programming language that allows you to write applications that can run on the client side or server side

Junior

What's the difference between null and undefined?

Show Answer

Undefined is a value that JavaScript assigns to variables that have not been assigned a value.

 

Null is a value that JavaScript assigns to variables that have been assigned a value but that value is null.

Junior

What is === operator?

Show Answer

The === operator is used to compare two values and types. It returns true if both values and types are equal, and false if they are not equal.

Junior

What are all the looping structures in JavaScript?

Show Answer

There are three looping structures in JavaScript:

  • For Loop
  • While Loop
  • Do While Loop
Junior

What is break and continue statements?

Show Answer

Break and continue statements are used to exit a loop or switch statement.

 

Break is used to exit a loop

 

Continue is used to skip the current iteration and continue to the next iteration.

Junior

What boolean operators can be used in JavaScript?

Show Answer

There are three boolean operators in JavaScript:

  • &&
  • ||
  • !
Junior

Explain passed by value and passed by reference.

Show Answer

In Pass by value, function is called by directly passing the value of the variable as an argument. So any changes made inside the function does not affect the original value.

 

In Pass by Reference, Function is called by directly passing the reference/address of the variable as an argument. So changing the value inside the function also change the original value. In JavaScript array and Object follows pass by reference property.

Junior

What are object prototypes?

Show Answer

The prototype is an object that is associated with every functions and objects by default in JavaScript, where function's prototype property is accessible and modifiable and object's prototype property is not visible

Junior

What are callbacks?

Show Answer

A callback is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

Junior

What is the use of a constructor function in javascript?

Show Answer

A constructor is a special function that creates and initializes an object instance of a class. The purpose of a constructor is to create a new object and set values for any existing object properties.

Junior

What is DOM?

Show Answer

The Document Object Model (DOM) is an API for HTML and XML documents. It is the programming interface for the HTML and XML documents.

Junior

What are arrow functions?

Show Answer

Arrow functions are a new syntactic construct in JavaScript. They are a shorter way to write function expressions.