Join Login Create a Request

JavaScript Interview Questions and Answers

JavaScript Interview Questions and Answers


General JavasScript Interview Questions and answers.

What are javaScript data types?

Primitive data types

  1. Boolean
  2. Number
  3. String
  4. BigInt
  5. Symbol
  6. Null
  7. Undefined

Objects which are collections of things.

What is JavaScript?

It is a server-side and client-side scripting language. It was until recently that javascript started being used as a backend language after the inception of NodeJS. 

javascript is also an object-oriented programming language.

What are advantages of JavaScript?

  • Popular, support
  • Third-party libraries
  • Interoperability - you can use javascript with other languages
  • Flexibility - Can be used on the frontend or the backend

Difference between JavaScript and Java

Java is an object-oriented programming language whereas JavaScript is a client side scripting language. Java must be compiled and JavaScript is only interpreted.

What is Hoisting in JavaScript

This is the default behaviour of JavaScript where variable and function declarations are moved to the top. So you can declare your variables at the bottom and use them at the top without any problems.

my_func();  // Outputs " Hello world! "

function my_func(){ 
  console.log(" Hello world! ");

What is negative infinity in JavaScript?

This is a number you can get if you divide a negative number by zero.

n_infinity = -10/0

What is a named function in JavaScript?

A named function declares a name as soon as it is defined. Here is an example:

function named_func(){
   console.log("This is a named function")

What is a callback function in JavaScript?

A callback function is a function which is executed after another function has finished execution. A callback function is passed as an argument or option to another function so that it's executed in that function. Here is how to define a callback function.

function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;

function myCalculator(num1, num2, myCallback) {
  let sum = num1 + num2;

myCalculator(5, 5, myDisplayer);

What is the difference between Local and Session storage?

Local and session storage are both ways to store data in your browser.  Here are the differences between the two.

Session storage

Data stored in session storage is cleared after the session expired. Session storage will also clear when the browser is closed. 

Local storage

Just like session storage, it allows a developer to save key/value pairs in the browser and it's different from session storage because the data is not cleared after the session has expired. It can however be cleared manually in the browser or program setting.