JavaScript Interview Questions with answers updated in 2022 for User Interface Developers , Web Designers , Frontend Developers and Web Developers with JavaScript, JS ES6, ES7, ES8, OOPS, AJAX and Web API.


JavaScript

JavaScript or JS is a general purpose programming language used in both frontend and backend. JavaScript is also known as the programming language of web.

JavaScript is lightweight, JIT compiled and high level programming language which follows ECMA International standards. JS has dynamic typing (loosely typed) and is prototype based object-oriented programming language.

JavaScript is among the most popular and used programming language in world with 13.8 Million active developers. It is also the top programming language on Stack Overflow and Github.


Variables

JavaScript Variables are dynamic or loosely typed. A variable can store any type of data, like string, number, boolean, function, array, object etc. Variables are function scoped.

However JS ES6, introduced let and const for block scope. let is used for block scope and is recommended instead of var in modern javascript for mutable data. const is also block scoped with immutable value.

What is variable hoisting?

A variable is declared first and then used. If variable is declared on bottom and used earlier, the value of variable will be undefined. Only assigned values are hoisted in Javascript, like string, numbers etc. Undefined and function declaration can be used before declaration as they are not hoisted, and there is no assignment operator (=) in both.

Variable declaration is hoisted, but variable assignment is not hoisted.

var vs let vs const?

var is used to declare variables in javascript. JavaScript are loosely or dynamic typed and can store any type of data. However JS ES6 introduce let and const for block level scope. let is used to store mutable values, and const is uses to perform immutable values.

var vs let vs const
Property var let const
hoisting declaration temporal dead zone temporal dead zone
ScopeFunctionblockblock
Create Global propertyyesnono