Javascript Interview Questions

  • By
  • November 26, 2019
  • JavaScript
Javascript Interview Questions

Javascript Interview Questions ( Part 1 )

Question. What is the let & const in JavaScript? 


In modern javascript let & const are different ways of creating variables. In javascript, we use the var keyword for creating a variable(s). let & const keyword is introduced in ES6 with the vision of making 2 differing kinds of variables in javascript one is changeless and alternative is changeable.

 const: it’s used to create an immutable  variable. Immutable variables are variables whose value isn’t modified within the complete life cycle of the program. 

let: let is used to make a changeable variable. Mutable variables are normal variables like var that can be changed any number of times.

You can update a let variable, but you cannot redeclare const twice in the same scope. 

For Free, Demo classes Call: 8237077325
Registration Link: Click Here!

Question. What are the different types of error(s) available in JavaScript? 


Load time errors: Thrown an error which come up when loading a web page.

Run time errors: Thrown an errors that come due to misuse of the command inside the HTML language.

Logical Errors: Thrown an errors that occur due to the bad logic performed.

SyntaxError: It tells us that the syntax of the code is somehow invalid.

TypeError: Thrown an error When we have some value and it is not of a proper type.

ReferenceError — Thrown an error when we want to refer to some variable that doesn’t exist.

RangeError —Thrown an error when a value is not in the allowed range

URIError — Thrown an error when URI is invalid in URI-related methods. 

Question. What are the different type(s) of Scope Chain available in JavaScript? 


Every local scope has a connection with one or more scope in their back which forms a chain in program. This chain goes on until it met with the global scope in the program which is the root of this hierarchy. As every global scope doesn’t have a parent, so it is on the top of the chain. This is known as a scope chain in Javascript. 

The scope chain in the JavaScript program is basically used to resolve the values of the variable. Without this, it is difficult for a JavaScript to choose a certain value for a variable(s) if there are many variables defined at different scopes. 

Question. Explain MUL function in Javascript?


MUL means simple multiplication of numbers. It is a technique in which you pass a one value as an argument in a function and that function returns another function to which you pass the second value and the process go on. For example: x*y*z can be represented as:

function mul (x) ;



Question. Write a program to reverse a string in Vanilla JavaScript? 


There are some ways to reverse a string in JavaScript. These are:

Using in-built functions: the inbuilt function reverse() reverses the string directly. Here’ how: 


str = str.split(“”); // convert ‘jQuery’ to array

str = str.reverse(); // reverse ‘jQuery’ order

str = str.join(“”); // combines the reverse order values.

alert ( str )

First split the string to associate array, then reverse an array and after that join the characters to form a string. 

Using a loop: 1st, count the number of characters in a string, then apply a decrementing loop on an original string which starts from the last character and prints each character until the count becomes zero. 

Question. In Javascript, How we can redirect a page to another page ? 


There are different ways to redirect page to another page in the JavaScript program. These are:

Using location.href: to redirect page. In Java Course in Pune, we can go back to access the original document.

Syntax: href =“” 

Using location.replace: Another approach to redirect page. In this, it is not possible to navigate back to the original document by clicking on the back button as it removes the URL of the original document.

Syntax: .replace(”;”); 

Question. List some of the Design patterns in JavaScript programming? 


in javascript, a programmingThe design pattern is a general reusable solution to a commonly occurring problem in software development. Some of the design patterns are as follows: 

Creational design pattern: These patterns dealt with the mechanism of object creation which optimize object creation with the basic approach.

Structural design pattern: these patterns alter completely different classes and objects to produce new functionality.

Behavioural Patterns: These patterns are to improve communication between objects and to recognize patterns.

Concurrency design patterns: These patterns handle with multi-thread programming paradigms.

Architectural style patterns: These patterns used to alter architectural styles. 

Question. What is difference between Array.splice() and Array.slice() method in JavaScript? 


The array.slice() removes items from the array and then return those removed items as an array whereas array.slice() method is selected items from an array and then those elements as a new array object. 

The splice() method have an effect ons the original array whereas slice() method doesn’t affect the original array.

Splice() method takes n number of arguments whereas slice() will take solely 2 arguments. 

Syntax of splice(): array.splice(index, how many, item1, ….., itemX)

Syntax of slice(): array.slice(start, end) 

Question. How to add and remove properties to object dynamically In Javascript ? 


we can add a property to an object using object.property_name =value, delete object.property_name is used to delete a property. 


let user = new Object();

// adding a property’Anil’;

user.age =25;


delete user.age;


Question. Explain Promise in JavaScript?


A promise is an object which is used to produce a value that may give results in the future. The value will be resolved value or it will be a reason that tells why the worth isn’t resolved.

A promise can be of three states:

Fulfilled: The operation is completed and the promise has a specific value.

Rejected: The operation failed and promise has a reason which shows why the operation failed.

Pending: The operation is not fulfilled or rejected, means it has not completed yet. 

Question. How to remove duplicates from JavaScript Array? 


There are many ways to remove duplicates from JavaScript array. These are described below with examples:

  1. By using Set: It is the simplest approach to remove duplicates. Set is an inbuilt object to store unique values in an array. Here’s how we use set:

function uniquearray(array)

As within the above code, you created a set of an array which automatically eliminates the duplicate values. 

  1. By using Filter: Another approach to remove duplicates from an array is applying filter on an array. Here’s how we use filter:

function unque_array (arr)

return unique_array }


  1. By using for loop: In this, we can use for loop to remove duplicates. In this we make an empty array in which those elements will be added from the duplicate array which are not present in this before. we will get AN array that has distinctive parts. Code to implement this:

Array dups_names = [‘Ron’, ‘Pal’, ‘Fred’, ‘Rongo’, ‘Ron’];

function dups_array(dups_names) ;



return Object.keys(unique);} // Ron, Pal, Fred, Rongo


These are the most 3 methods utilized in JavaScript to get a singular array. 

Question. How to get an element ( in HTML ) by class in JavaScript ?


document.getElementsByClassName() method is used in Javascript to get an element with a class name. 

Question. Explain the difference between null, undefined or undeclared JavaScript variable? 


Null is a value that can be assigned to a variable or an object. 

Undefined means a variable has been declared but no value is assigned to it. This type of variable is declared itself to be undefined.

 Undeclared means that the variable has declared without any datatype.

Null, Undefined are primitive data types whereas Undeclared is not a primitive data type. 

Question. List the difference between primitive and non-primitive JavaScript data types? 


In javascript, there are some primitive data types such as numbers, strings, Boolean, undefined, null and anything other than these data types are known as non-primitive such as objects and functions. 

Primitive data types are immutable while non-primitives are mutable.

Primitives are well-known changeless as they can not be modified once they created however non-primitive are changeable, means that once AN object is formed, it may be modified. 

Primitive data types are compared with their values, it means two values are strictly equal if they have the same data type and holds the same value.

Non-primitives are not compared with values. 

Question. How to add the new property in existing function JavaScript? 


It is easy to add a new property in an existing function by just giving value to the existing function it. For example, let Java Classes in Pune have an existing object person, to give new property check the below code: “India”;

The new property “country” has added to the person object. 

Question. What is the difference between deep and shallow object coping in JavaScript programming? 


Some differences are:

Deep copy means copies all values or/and properties recursively in the new object whereas shallow copy copies only the reference in an object in the program. 

In a deep copy, changes in the new object do not show in the original object whereas, in a shallow copy, changes in new objects will reflect in the original object in the program. 

In a deep copy, original objects do not share the properties with new object whereas, in a shallow copy, they do.

For Free, Demo classes Call: 8237077325
Registration Link: Click Here!

Javascript Interview Questions ( Part 2 )

Javascript Interview Questions Part 2

Question. How to call a function in JavaScript in every x seconds? 


In JavaScript, we use the function setInterval() to call any function in every x seconds.

Syntax: setInterval(function, milliseconds, param1, param2, …) 

Function: it is a required parameter (function call) which includes the function to be executed. 

Milliseconds: required parameter ( second in milliseconds ) which tells how often the function will execute.

Others are an additional parameter. 

For example: setInterval(function (), 3000);

In the above example, this function calls hello function in every 3 seconds. 

Question. Explain spread operator in JavaScript? 


The spread operator expands an expression in places where multiple argument(s)/variable(s)/element(s) are needed to present. It represents with three dots (…).

For example:

var mid = [3, 4];

var newarray = [1, 2, …mid, 5, 6];


// [1, 2, 3, 4, 5, 6]

In the above example, instead of appending mid array, it rather expands in the new array with the help of spread operator. This is how the spread operator works in JavaScript. 

Question. In JavaScript how host and  native objects are different ?


Host objects in These are those objects which environment gives. It means they are different for different environments. For example, browsers include objects such as windows in Javascript but Node.js environments give objects such as Node List.

Native Objects in these are built-in objects in JavaScript. They are also known as Global Objects because they will be available to you independent of any environment. 

Question. Explain higher-order functions in JavaScript? 


Higher order function is the best feature of functional programming which is available in JavaScript. It is the function which takes a function as an argument and returns a function as a result in program. following are the inbuilt higher-order functions are mapping, filtering, reduction, zipping, etc.

 Question. Please explain equality operators in JavaScript? 


Equality operators in Javascript

Equality operator (==)

The equality operator applies strict comparison if they are the same. An equality operator converts the operands if they are not of the same type In javascript.  


 x == y 


 10   ==  10        // true

“10”  ==  10        // true

 10   == ’10’       // true

 0   == false     // true

 0   == null      // false 

   0   == undefined   // false

 null  == undefined   // true

Inequality Operator (!=)

In javascript, the inequality operator returns true if the operands are not equal ( != ). JavaScript attempts to convert the operands to an appropriate type for the comparison If the two operands are not of the same type in Javascript. 


y != x 


10 !=   20     // true

10 !=  “10”    // false

10 !=  ’10’    // false

1 !=  true   // false

0 !=  false  // false 

Identity / strict equality in Javascript (===)

The identity operator returns true if the operands are strictly equal with no type of conversion in Javascript. 


a === b 


30 === 30   // true

30 === ’30’ // false 

Non-identity / strict inequality in Javascript ( !== ):

In Javascript, the non-identity operator returns true if the operands are not equal and/or not of the same type. 


a !== b


32 !== ’32’ // true

41 !== 31   // true 

Question. What are anonymous functions in JavaScript?


An anonymous function is a function without a name (as its name implies). They are most popularly used to define function expressions in programming. 


 const showName = function (name){




//output: Tom 

Question. What is the difference between local and global scope in JavaScript?


The difference between global and local variables is Global variables are declared outside any function block and they can be used on any function in the program. Local variables are declared inside a function block and can be used only inside that function block. It is possible to have local variables with the same name in different functions in the program. 

// a global variable

var species = “human”; 

function transform() {

  // a local, function-scoped variable

  var species = “werewolf”;



Question. What is the use of settimeout function in JavaScript? 


In Javascript, setTimeout is a native JavaScript function, which calls a function or executes a code snippet after a specified delay (in milliseconds).

 Syntax : setTimeout(function, milliseconds, params) 

Question. List a few advantages of using JavaScript? 


Few advantages of Javascript

Few Advantages Of Javascript

Javascript is executed on the user’s computer, the meaning is that whatever you do in Javascript will not add any processing strain on the server. and that’s why it is called as the client-side programming language. And this feature makes your sites responsive ( responce or arrange according to device width) for the end user and less expensive for you in terms of server traffic. 

With the help of Javascript, you can create highly responsive interfaces  (UX/UX) which will improve the user experience and provide dynamic functionality, without waiting for the server to show another page. 

If you want to make online systems available offline and sync automatically once the computer goes online, then Javascript is the best technology to make it possible for you, you can use. you can do this using the right browser add-ons (Such as Google or Yahoo Browser Plus). 

Content loading and changing it dynamically. Using Ajax in Javascript you can load content into the document if and when the user needs it, without reloading the entire page. 

Question: List few differences between JAVA and JavaScript?  


The difference between Java and JS 


Java – Java is a general-purpose object-oriented programming language (Heavyweight), which runs on JVM.

 JavaScript – Javascript is a Scripting (Lightweight), used to create dynamic web pages. 

Language Type

Java is a strongly typed language. 

JavaScript is weakly or loosely typed language. 

Platform to run

Java code can run on JVM, which makes it platform-independent.

 JavaScript app runs on browser only, it is developed for browser only. 

Objects based/oriented:

Java is an object-oriented language. 

JavaScript is objects based. 


Java Programs uses more memory to execute.

JavaScript programs uses less memory to execute.. 

Compiled Vs Interpreted

Java is considered as both ( Compiled & Interpreted ) and JavaScript has interpreted scripting language.

 Question: Is JavaScript multithreaded or single-threaded? 

Answer: JavaScript is single-threaded. 

 Question: In Javascript, have we possible to implement 301 redirects?


JavaScript runs on the client machine. Error 301 is response code that is sent by the server as a response. So it is not possible to do 301 Redirects In the case of JavaScript. As we know javascript is mostly used for client side script, if a developer using javascript for client side application in that case we can not do any implementation for server side errors. 

Question:  In JavaScript, How we can get inner Html of an element?


In JavaScript, InnerHTML property of DOM is used to get inner Html of HTML an element.

Example Usage:

This is inner Element

            var  inner= document.getElementById(“inner”).innerHTML ;

            console.log(inner); // This is inner Element

            document.getElementById(“inner”).innerHTML = “Html changed!”;

            var  inner= document.getElementById(“inner”).innerHTML ;

            console.log(inner); // Html changed!


Question: Explain Event bubbling and Event Capturing in JavaScript?


Event Capture and Bubbling: In HTML DOM API there are two ways of event propagation and determines the order in which events will be received. The two ways in which ar Event bubbling and Event Capturing. The first technique event bubbling directs the event to its meant target, and also the second is named event capture within which the event goes all the way down to the part.

Down To The Part

Event Capture

The capture procedure is never used however once it’s used it proves to be very useful. This process is also called ‘trickling’. In this process, the event is captured first by the outermost element and then propagated to the innermost element. For example:

From the top of the provided example, suppose the click event did occur in the ‘li’ element, in that case capturing event it will be first handled ‘div’, then ‘ul’ and at last the target part are hit that’s ‘li’

Event Bubbling

Bubbling just works like the bubbles, the event gets handled by the innermost element and then propagated to the outer element.

From the above example, suppose the click event did occur within the ‘li’ part in bubbling model the event are handled initial by ‘li’ then by ‘ul’ and at last by ‘div’ element. 

Question: In Javascript, How can we import all exports of a file as an object. 


import * as object name from ‘./file.js’

is used to import all exported members as an object.

You can simply access the exported variables or methods using dot (.) operator of the object.





 Question: Explain Arrow functions? 


An arrow function is a concise and short way to write function expressions in Es6 or above. Arrow functions cannot be used as constructors and also does not supports this, arguments, super, or keywords. It is best suited for non-method functions. An arrow function looks like const function_name= ()=>{}

const greet=()=>{console.log(‘hello’);}


For Free, Demo classes Call: 8237077325
Registration Link: Click Here!

Javascript Interview Questions ( Part 3 )

Javascript Interview Questions Part 3

Question: Explain function hoisting in JavaScript?


JavaScript’s default behavior that permits moving declarations to the top is called Hoisting. The 2 ways that of creating functions in JavaScript are function Declaration and function Expression. Let’s find out more about these: 

Function Declaration

A function with the specific parameters is known as function declarations. To create a variable in JavaScript is named declarations.


hoisted(); // logs “foo”

function hoisted()


Function Expression

When a perform is made by mistreatment Associate in Nursing expression it’s known as perform expression.


notHoisted(); // TypeError: notHoisted is not a function

var notHoisted = function() ; 

Question: How we can remove all the duplicate values from a array in JavaScript? 


We can use array.indexOf method to check a value exists or not. See below example to remove duplicate values.

let duplicates = [‘delhi’,’kanpur’,’kanpur’,’goa’,’delhi’,’new york’];

function removeDuplicatesValues(arr)


return unique_array



Question: What is console.time() and console.timeEnd()? What is its syntax of it, and why is it used for?


The console object has time() and timeEnd() methods that help with analyzing performance of pieces of program/ code. we need to first call console.time() by providing a string argument ( “optional”), then the code that you want to test, then call console.timeEnd() with the same string argument( which is optional ). You’ll then see the time ( execution time ) it took to run the code in your browser console. Here’s an example: 

console.time(“Time this”); 

for (var someVar = 0; someVar< 10000; someVar++) {

  // block of code goes here..!


 console.timeEnd(“Time this”);  

Question: Explain JavaScript Debounce Function? 


A Debounce is a higher-order function, which is a function that returns another function, Debouncing in JavaScript is a practice used to improve browser performance. There can be some functionality in a very web page which needs long computations. If such a method is invoked frequently, it would greatly have an effect on the performance of the browser, as JavaScript is a single threaded language. Debouncing could be a programming practice used to make sure that time-consuming tasks don’t fire so typically, that it stalls the performance of the net page. In other words, We can say, Debounce limits the rate at which a function gets invoked.

 Question: In javascript, What is the difference between the declaration of var x =1; and x=1;? 


‘var x = 3’ can create a variable among the current block scope. Given this is often declared in an exceedingly function, x won’t be available outside it, unless explicitly returned. 

‘x = 3’ can create a variable among the world scope. Thus, the other code will access and alter its value. It’s typically a bad practice to use variables in an exceedingly global scope. 

Question: Explain JavaScript Accessors ? 

Answer: JavaScript Accessors 

In Javascript, Getters and Setters allow you to build useful shortcuts for accessing and mutating data within an object. This can be seen as an alternative to having two different functions with an object that are used to get and set a value. 

Question: What is difference between module.exports and export? 


            The module may be a plain JavaScript object with Associate in Nursing exports property. Exports may be a plain JavaScript variable that happens to be set to module.exports. At the top of your file, node.js will basically ‘return’ module.exports to the require function. A simplified way to view a JS come in Node might be this:

var module =  };

var exports = module.exports;

// your code

return module.exports; 

If you set a property on exports keyword, such as exports.someVar = “Some text goes here…”;, that will set module.exports.a as well because objects are passed around as references in JavaScript, which means that if you set multiple variables to an equivalent object, they are all the same object; so then exports and module.exports are the same objects. 

But if you set exports to something new, it will no longer be set to module.exports, so exports and module.exports are no longer the same objects. 

Question: What are exports and imports? 


Imports and exports facilitate us to put in writing standard javascript code. Using Imports and exports we can split our code into multiple files. Imports permit taking just some specific variables or methods of a file. We can import ways or variables that are exported by a module. See the below example for more detail.


import name,age from ‘./person’;




let name =’Alex’, occupation=’developer’, age =26;

export ; 

Question: What is the difference between let and var? 


Both var and let are used for variable/ method ( function ) declaration in javascript however the most distinction between let and var is that var is function scoped whereas let is block scoped.

 Question: List the comparison operators supported by Javascript? 


Javascript supports below comparison operators

> Greater than

< Less than

= Greater than or equal to

== Equal to

!= Not Equal to

=== Equal to with datatype check

!== Not equal to with datatype check 

Question: List some Unit Testing Frameworks JavaScript 


Below is the list of few most Popular Javascript Unit Testing Frameworks:










 Question: How do you declare variables in Javascript? 


            In Javascript var ( variables ) are declared using the var keyword.A variable must begin with A letter, $ or _.

  1. var myVar=”Online Interview Questions”;

PS: All variables in Javascript are Case sensitive.

Also, read Advanced JavaScript Interview Questions 

Question: What are different types of Popup boxes available in Javascript? 


In Javascript there are three forms of Popup Boxes are available, they are




Question: How to convert Javascript date to ISO standard? 


toISOString() method is used to convert javascript date to ISO standard.


var date = new Date();

var n = date.toISOString();


// YYYY-MM-DDTHH:mm:ss.sssZ 

Question: How to you change ( or modify ) the title of the page by using JavaScript? 


You can change ( or modify )  the title of a webpage using setting the title property of the document object.

Example usage

document.title=”My New Title”;

 Question:. How to clone an object in Javascript?


Object.assign() method is used for cloning an object in Javascript.Here is sample usage

var x = ;

var y = Object.assign(, x);

 Question: In JavaScript, How we can encode and decode a URL? 


encodeURI() function is used to encode an URL in Javascript.It takes a url string as parameter and return encoded string. Note: encodeURI() did not encode characters like / ? : @ & = + $ #, if you have to encode these characters too please use encodeURIComponent().


var uri = “my profile.php?name=sammer&occupation=pāntiNG”;

var encoded_uri = encodeURI(uri);

decodeURI() function is used to decode an URL in Javascript.It takes a encoded url string as parameter and return decoded string. Usage:

var uri = “my profile.php?name=sammer&occupation=pāntiNG”;

var encoded_uri = encodeURI(uri);


 Question: Explain Typecasting in Javascript? 


Typecasting is the concept of converting variables from one type to another, In Programming whenever we need to convert a variable from one data type to a different Typecasting is used. In Javascript, we are able to do this via library functions. There are basically 3 typecasts are available in Javascript Programming, they are: 

Boolean(value): Casts the inputted value to a Boolean

Number(value): Casts the inputted value to an Integer or Floating point Number.

String(value) : Casts the inputted value value a string 

Question: List out all the possible and different ways of empty an array in Javascript? 


In Javascript, there are some ways to empty an array, here are  4 major

By assigning an empty array.

var arr1 =[1,4,5,6];


By assigning array length to 0.

var arr2 =[1,4,5,6];


By popping the elements of the array.

var arr2 =[1,4,5,6];

while(arr.length > 0)

By using .splice() .

var arr =[1,4,5,6];


Question: In JavaScript, What is the ‘Strict’ mode and how can we enable it? 


Strict mode is a way to introduce better way for error-checking into your code. In Javascript, When you use strict mode, you can’t, for example, use implicitly declared variables, or assign a value to a read-only property, or add a property to an object that is not extensible.

You can enable strict mode by adding “use strict”; at the beginning ( at the start of code ) of a file, a program, or a function. This kind of declaration is understood as a directive prologue.  If it’s declared in a global context (outside the scope of a function), all the code in the program is in strict mode. If it’s declared in a very function, all the code in the function is in strict mode. 

Question: How can you create an array in Javascript? 


In Javascript there are three different ways to create an array. They are 

By array literal


var myArray=[value1,value2…valueN]; 

By creating an instance of Array


var myArray=new Array();

 By using an Array constructor


var myArray=new Array(‘value1′,’value2′,…,’valueN’);

For Free, Demo classes Call: 8237077325
Registration Link: Click Here!

Javascript Interview Questions ( Part 4 )

Javascript Interview Questions Part 4

Question: What is Javascript BOM?

BOM stands for “Browser Object Modal” that permits Javascript to ‘talk’ to the browser, no standards, modern ( updated browsers ) browsers implement similar BOMS – window, screen, location, history, navigator, timing, cookies. 

Question: What does the instanceof operator do?

To check whether the object is an instance of a class or not in Javascript, we can implement instanceof operator: 

Example Usage

Square.prototype = new Square();

console.log(sq instanceof Square); // true 

Question: How to get the primitive value of a string in Javascript?

In Javascript valueOf() method is used to get the primitive value of a string.

Example Usage:

var myVar= “Hi!”


Question: How to get the last index of a string in Javascript?

 in Javascript, string.length-1 is used to get the last index of a string content

Example Usage:-

var myString=”JavascriptQuestions”;


Question: List HTML DOM mouse events?

HTML DOM mouse events









Question: What will happen if an infinite while loop is run in Javascript?

The program will crash the browser. 

Question: In Javascript are calculations with fractional numbers guaranteed to be precise?

NO,  In Javascript, calculations with fractional numbers are not guaranteed to be precise but it will be in the future with advanced javascript.

 Question: What Are Design Patterns?

As I said before, style patterns are reusable solutions to usually occurring issues in code style. Let’s take a glance at a number of the categories of design patterns. 


How does one create a pattern? Let’s say you recognized a usually occurring downside, and you have your own unique solution to this problem, which isn’t globally recognized and documented. You use this solution every time you encounter this problem, and you think that it’s reusable and that the developer community could benefit from it. 

Does it immediately become a pattern? Luckily, no. Oftentimes, one might have smart code writing practices and easily mistake one thing that appears like a pattern for one when, in fact, it is not a pattern.

How are you able to apprehend once what you think that you recognize is actually a design pattern? 

By obtaining different developers’ opinions regarding it, by knowing about the process of creating a pattern itself, and by making yourself well acquainted with existing patterns. There is a part a pattern should undergo before it becomes a full-fledged pattern, and this is called a proto-pattern. 

A proto-pattern could be a pattern-to-be if it passes an exact amount of testing by varied developers and situations wherever the pattern proves to be helpful and provides correct results. There is quite a large amount of work and documentation—most of which is outside the scope of this article—to be done in order to make a fully-fledged pattern recognized by the community.


As a style pattern represents smart apply, an anti-pattern represents bad practice. 

An example of AN anti-pattern In disign patterns, would be modifying the object class prototype. Almost all objects in JavaScript inherit from Object (remember that JavaScript uses example-based inheritance) therefore imagine a situation wherever you altered this prototype. Changes to the article example would be seen all told of the objects that inherit from this prototype—which would be most JavaScript objects. This is a disaster waiting to happen. 

Another example, kind of like one mentioned higher than, is modifying objects that you don’t own. An example of this would be overriding a function from an object used in many scenarios throughout the application. If you’re operating with an oversized team, imagine the confusion this would cause; you’d quickly run into naming collisions, incompatible implementations, and maintenance nightmares. 

Similar to how it is useful to know about all of the good practices and solutions, it is also very important to know about the bad ones too. This way, you can recognize them and avoid making the mistake up front.

 Design Pattern Categorization

Design patterns may be classified in multiple ways in which, however the foremost popular one is that the following:

 Creational design patterns

Structural design patterns

Behavioral design patterns

Concurrency design patterns

Architectural design patterns

Creational Design Patterns 

These patterns manage object creation mechanisms that optimize object creation compared to a basic approach. The basic variety of object creation might end in design issues or in more quality to the planning. Creational style patterns solve this downside by somehow dominant object creation. Some of the popular design patterns during this class are: 

Factory method

Abstract factory




 Structural Design Patterns

These patterns deal with object relationships. They make sure that if one a part of a system changes, the entire system doesn’t need to change along with it. The most popular patterns in this category are: 








Behavioral Design Patterns

These varieties of patterns acknowledge, implement, and improve communication between disparate objects in a system. They help ensure that disparate parts of a system have synchronized information. Popular examples of these patterns are: 

Chain of responsibility










Concurrency Design Patterns

These varieties of style patterns manage multi-threaded programming paradigms. Some of the popular ones are: 

Active object

Nuclear reaction


Architectural Design Patterns

Design patterns which are used for architectural purposes. Some of the most famous ones are:

MVC (Model-View-Controller)

MVP (Model-View-Presenter)

MVVM (Model-View-ViewModel)

In the following section, we have a tendency to area unit reaching to take a {better|a more in-depth} verify a number of the same style patterns with examples provided by Java Traininig in Pune  for better understanding. 

Question: What are the primitive data types in JavaScript?

A primitive is a basic data type that’s not designed out of other data types. It can only represent one single value. All primitives ar built-in data types by necessity, (the compiler has to know about them,) but not all built-in data types are primitives.

In JavaScript there are five primitive data types are available they are number, string, boolean, undefined and null are available. Everything else in Javascript is an object.

 Question: How to calculate Fibonacci numbers in JavaScript?

Calculating Fibonacci series in JavaScript

Fibonacci numbers ar a sequence of numbers wherever every value is that the total of the previous 2, beginning with zero and one. The first few values are 0, 1, 1, 2, 3, 5, 8, 13 ,…, 

function fib(n) {

            var a=0, b=1;

            for (var i=0; i < n; i++) {

                        var temp = a+b;

                        a = b;

                        b = temp;


            return a;


 Question: What are the different types of Inheritance? Which Inheritance is followed in Javascript.

There are two types of Inheritance available in Object Oriented Programmings Classic and Prototypical Inheritance. Javascript follows Prototypical Inheritance.

  1. What is output of undefined * 2 in Javascript?

nan is output of undefined * 2. 

Question: What is output of undefined * 2 in Javascript?

nan is output of undefined * 2. 

Question: Explain “use strict” ?

In Javascript, “use strict” is a directive that’s introduced in Es5 ( ECMAScript 5 ). The purpose of mistreatment “use strict” directive is to enforce the code is dead in strict mode. In Javascript  strict mode we can’t use a variable without declaring it. in Javascript, “use strict” is unheeded by earlier versions of Javascript files and libraries. 

Question: Describe negative infinity in JavaScript?

NEGATIVE_INFINITY property represents negative eternity and may be a number in javascript, that comes by ‘dividing negative number by zero’. It may be better understood as {a range|variety} that’s less than the other number. Its properties are as follows:

  • a number of objects needn’t be created to access this static property.
  • The values behave differently than the mathematical infinity:
  • Any positive price, as well as POSITIVE_INFINITY, increased by NEGATIVE_INFINITY is NEGATIVE_INFINITY.
  • Zero multiplied by NEGATIVE_INFINITY is NaN.
  • NaN multiplied by NEGATIVE_INFINITY is NaN.
  • NEGATIVE_INFINITY, divided by any negative price except NEGATIVE_INFINITY, is POSITIVE_INFINITY.
  • NEGATIVE_INFINITY, divided by any positive price except POSITIVE_INFINITY, is NEGATIVE_INFINITY.

Any number divided by NEGATIVE_INFINITY is zero. 

Question: Explain JavaScript Event Delegation Model?

In Javascript, Delegation Model is, When capturing and bubbling ( i.e. Event bubbling in Javascript ), permit functions to implement one single handler to several elements at one explicit time then that’s referred to as event delegation. Event delegation permits you to feature event listeners to at least one parent rather than given nodes. That particular listener analyzes bubbled events to search out a match on the child components. Many people suppose it to be difficult however actually, it’s very simple if one starts understanding it. 

Question: Explain Closures in JavaScript?

Closures are the mix of lexical environment and {function|and performance} inside that the function was declared. This allows JavaScript developers to put in writing higher, a lot of artistic, taciturn and communicatory codes. The closure can contains all the native variables that were in-scope once the closure was created.

Sure, closures appear to be complex and beyond the scope, but after you read this article, closures will be much more easy to understand and more simple for your everyday JavaScript programming tasks. JavaScript is a very functional-oriented and object-based language it gives the user freedom to use functions as the wish of the programmer. 

Question: What close() does in Javascript?

In Javascript close() method is used to close the current window. Also, in Javascript, window.close() method to ensure that this command is associated with a window object and not associated with some other JavaScript object. 

Question: Explain what is Javascript? List some data types supported by Javascript?


Javascript is an object-based scripting language commonly used to create and develop interactive web applications. It is first used by the Netscape, that provides access and manipulate to the HTML document object model (DOM), provides access to the browser object model (BOM).

Below is the list of data types supported by –








Manoj Patil Software Trainer  | SevenMentor Pvt Ltd

For Free, Demo classes Call: 8237077325
Registration Link: Click Here!

Call the Trainer and Book your free demo class now!!!

call icon

© Copyright 2019 | Sevenmentor Pvt Ltd.

Submit Comment

Your email address will not be published. Required fields are marked *