JavaScript is a high-level, dynamic, untyped, and interpreted programming language. It has been standardized in the ECMAScript language specification. Alongside HTML and CSS, it is one of the three essential technologies of World Wide Web content production; the majority of websites employ it and it is supported by all modern web browsers without plug-ins or any kind of other extensions.
“Javascript is the duct tape of the Internet.”

Let’s starts with some common Qs about JavaScript.
- JavaScript is developed by- Netscape Communications Corporation Mozilla Foundation, Ecma International.
- It designed by- Brendan Eich
- JavaScript is called- JS
- The extension filename of JavaScript- .js
- JavaScript Media type- application/javascript, text/javascript.
- The current version of JavaScript- ECMAScript 2018.
In this guide, you’ll find example interview Qs and answers you can refer to when seeking a new JavaScript developer to make your dynamic user interfaces come to life. You’ll also get some practical Qs on how to use these Qs to reliably identify results.
Q 1. Is JavaScript and JScript the same?
Answer. Both JavaScript vs JScript is designed to make dynamic web pages and interactive content.
- Javascript is a scripting language (supports scripts) for Web pages but it is also used in non-browser environments as well. It is a powerful, lightweight, interpreted, scripting language with first-class functions (i.e. the language supports passing functions as arguments to other functions).
- JScript is also a scripting language, much similar to JavaScript. It is a dialect of the popular ECMAScript standard reverse-engineered by Microsoft. JScript is subsidy by Microsoft and used in one of the most popular web browsers Microsoft’s Internet Explorer. JScript can also be called “Microsoft’s JavaScript”.
Difference | JavaScript | Jscript |
Type | Scripting language | Scripting language owned by Microsoft. |
Simplicity | It needs to write scripts manually. | Same as JavaScript in this context. |
Browser Compatibility | It needs to handle multiple browsers compatibility. | Only support by Microsoft’s internet explorer. |
Active Content Creation | Does not support active content creation. | With JScript, you can create active online content for WWW. |
Object Access | JavaScript cannot access web browser objects. | JScript can easily access- objects exposed by internet explorer. |
Q 2. Justify the use of let
and const
in JavaScript?
Answer. Earlier in javascript, developers use the var
keyword for creating variables. let & const
keyword is introduced in version ES6 with the vision of creating two different types of variables in javascript one is immutable and the other is mutable. The use if let
and const
in JavaScript:
- let
let
is used for variable declaration as it comes as an improvement to the var
declarations. let
is a block code bounded as {}. So a variable declared in a block with the let
is only available for use within that block.
- Example:
let greeting = "say Hi";
let times = 4;
if (times > 3) {
let hello = "say Hello instead";
console.log(hello);//"say Hello instead"
}
console.log(hello) // hello is not defined
- const
Variables declared with the const
maintain constant values. const
declarations share some similarities with let
declarations.
Like let
declarations, const
declarations can only be accessed within the block it was declared in.
const
cannot be updated or re-declared
This means that the value of a variable declared with const
remains the same within its scope. It cannot be updated or re-declared. So if we declare a variable with const
.
- Example:
const greeting = "say Hi";
greeting = "say Hello instead";//error : Assignment to constant variable.
Q 3. Explain the MUL function in JavaScript?
Answer. MUL means a simple multiplication of numbers. It is a technique in which you pass one value as an argument in a function and that function returns another function to which you pass the second value and the process goes on. Multiplies two expressions. This is the functional equivalent of the (*) operator.
Q 4. List the Frameworks and Data types supported by JavaScript?
Answer. The frameworks used by JavaScript are:
- Node.js
- Angular.js
- React
- Vue.js
- Ember.js
- Meteor
- Backbone.js
Data types supported by JavaScript are:
- Symbol
- String
- Boolean
- Null
- Undefined
- Number
- Object
Q 5. How you can redirect a page to another page in JavaScript?
Answer. There are several ways to redirect the page to another page in JavaScript. These are:
- Using location.href: It is the first approach to redirect page. In this, we can go back to access the original document.
- 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.
Q 6. Clarify some design patterns in JavaScript?
Answer. The design pattern is a reusable solution to a commonly occurring problem in software design. Some of the design patterns are:
- Behavioral Patterns:
These patterns are to improve communication between objects and to recognize patterns. Visitor, states, strategy, Memento, Mediator, Iterator, Command, Chain of responsibility and observer are examples of Behavioral patterns. - Creational design pattern:
These patterns deal with the mechanism of object creation which optimizes object creation with the basic approach. Factory method, Abstract Factory, Builder, Prototype, and Singleton are the categories of Creational design pattern. - Concurrency design patterns:
These patterns handle with multi-thread programming paradigms. Some popular categories of concurrency design patterns are Scheduler, Nuclear reaction, and Active object. - Structural design pattern:
These patterns deal with different classes and objects to provide new functionality. Adapter, Bridge, Composite, Decorator, Facade, Flyweight, and proxy are the categories od structural design patterns. - Architectural design patterns:
These patterns used to deal with architectural designs. Like: MVC (Model-View-Controller), MVVM (Model-View-ViewModel), and MVP (Model-View-presenter).
Q 7. Explain promise in JavaScript?
Answer. A Promise is a proxy for a value not necessarily known when the promise is created. It allows the developers to associate handlers with asynchronous action’s eventual success value or failure reason. Essentially, a promise is a returned object that you can attach callbacks to, instead of passing callbacks into a function.
- 3 states to a promise:
pending
: awaiting promise response.resolve
: promise has successfully returned.reject
: failure occurred.
- Syntax:
new Promise(executor);

Q 8. What are the advantages of using JavaScript?
Answer. Some key advantages of JavaScript are:
- JavaScript is an easy language to learn.
- It is comparatively fast for the end-user.
- Easy to debug and test.
- JavaScript is platform-independent.
- It works on the client6-side.
- Also, has powerful frameworks.
- Event-based programming language.
- Procedural programming capabilities.
Q 9. How to get inner HTML of an element in JavaScript?
Answer. InnerHTML property of HTML DOM is used to get inner Html of an element in JavaScript.
- Example:
<script type="text/javascript">
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!
</script>
Q 10. What are the Arrow functions in JavaScript?
Answer. Arrow functions were introduced in ES6. Arrow functions allow the developers to write shorter function syntax.
hello = () => {
return "Hello World!";
}
An arrow function expressions is a syntactically compact alternative to a regular function expression, but this function has its own bindings to the arguments
, super
, this
, and new.target
keywords.
Q 11. How to encode and decode a URL in JavaScript?
Answer. Encode and Decode a URL in JavaScript:
- 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().
Usage:
var uri = "my profile.php?name=alex&occupation=danciNG";
var encoded_uri = encodeURI(uri);
- decodeURI() function is used to decode a URL in Javascript. It takes an encoded URL string as a parameter and returns decoded string.
Usage:
var uri = "my profile.php?name=alex&occupation=danciNG";
var encoded_uri = encodeURI(uri);
decodeURI(encoded_uri);
Q 12. Classify the different ways of empty an array in javascript?
Answer. In Javascript, there are many ways to empty an array, here are the four major ways to empty an array:
- By poping the elements of the array.
var arr2 =[1,4,5,6];
while(arr.length > 0) {
arr.pop();
}
- Assigning array length to 0.
var arr2 =[1,4,5,6];
arr2.length=0;
- Using .splice().
var arr =[1,4,5,6];
arr.splice(0,arr.length)
- By assigning an empty array.
var arr1 =[1,4,5,6];
arr1=[];
Q 13. How to remove duplicates from JavaScript Array?
Answer. The three main approaches to remove duplicates from JavaScript Array:
- By using Set:
It is the simplest way to remove duplicates because Set is an inbuilt object to store unique values in an array.
How to use set:
function uniquearray(array) {
let unique_array= Array.from(set(array))
return unique_array;}
By this code, you can easily create a set of an array that automatically eliminates duplicate values in JavaScript.
- By using Filter:
This is another way to remove duplicates from an array. In the Filter method, it requires three arguments: Current element, Index of the current element, and Array.
How to use Filter:
function unque_array (arr){
let unique_array = arr.filter(function(elem, index, self) {
return index == self.indexOf(elem); }
return unique_array }
console.log(unique_array(array_with_duplicates));
- By using for loop:
This is also a way to remove duplicates, but in this developer make an empty array in which those elements will be added from the duplicate array to get the unique elements.
Code use as:
Array dups_names = ['Tom', 'Pal', 'Fred', 'Rongo', 'Ron'];
function dups_array(dups_names) {
let unique = {};
names.forEach(function(i) {
If (!unique[i]) {
unique[i] = true; }
});
return Object.keys(unique);} // Tom, Pal, Fred, Rongo
Dups_array(names);
Q 14. Are the results of 6 + 4 + ‘45’ and 6 + 4 + 45 the same?
Answer. No, the results should be different from each other because the results for the two statements are very different from each other. 6 + 4 + 45 gives the result 55, which is the expected answer for the addition of numbers. But, 6 + 4 + ‘45’ returns 1045 as a result. This is because 45 is a string and 6 and 4 are numbers. The presence of the string specifies that the + operator is a string operator for concatenation rather than an arithmetic operator.
Q 15. What is null, undefined, and undeclared JavaScript variable?
Answer.
- Null
It can be assigned to a variable to represent no value. It is an assignment value.
var b = null;
console.log(b); //null
console.log(typeof b); //object
- Undefined
It means a variable has been declared but has not yet been assigned a value
var a;
console.log(a); //undefined
console.log(typeof a); // undefined
- Undeclared
If a variable is not declared then the browser throws an error.
console.log(nonDeclaredVariable);
// Uncaught ReferenceError: nonDeclaredVariable is not defined
// at <anonymous>:1:13
console.log(typeof nonDeclaredVariable); //undefined
Q 16. What is the purpose of ‘This’ operator in JavaScript?
Answer. The JavaScript this keyword refers to the object it belongs to. This has different values depending on where it is used. In a method, this refers to the owner object and in a function, this refers to the global object.
Q17. Explain the terms synchronous and asynchronous code.
Answer. The synchronous code is something that should be finished before anything else can happen, or in other words, the synchronous code is blocking. And the Asynchronous code is something in which actions can happen and is not dependent on other actions- in other words, it is non-blocking.
Q 18. Are “==” and “===” operators different in JavaScript?
Answer. “==” checks only for equality in value whereas “===” is a stricter equality test and returns false if either the value or the type of the two variables are different. So, the second option needs both the value and the type to be the same for the operands.
Q 19. How to Calculating the Fibonacci series in JavaScript?
Answer. Fibonacci Series is a sequence of numbers where the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.

function fibonacci(n) {
let arr= new Array(n+1);
arr[1]=1;
arr[2]=1;
for(let i=3;i<=n;i++)
{
arr[i]=arr[i-1]+arr[i-2];
}
for(let i=1;i<=n;i++)
{
console.log(arr[i]);
}
return;
}
Q 20. Brief the process of Create, Read, and Delete a cookie by using JavaScript?
Answer. The process of Create, Read, and Delete a cookie by using JavaScript:
- Cookie creating process-
The simple way to create a cookie is to assign a string value to the document.cookie object.
Syntax:
document.cookie = "key1 = value1; key2 = value2; expires = date";
- Reading a cookie-
It is just as simple as writing one for the developers because of the value document.cookie object is the cookie. So you can use this string whenever you want to access it.
This fulfills your two conditions:
- The document.cookie string will keep a list of anme= value pairs separated by semicolons.
- It is easy for the developers to use the string’s split() function to break the string into key and values.
- Delete a cookie-
If you want to delete a cookie, that subsequent attempts to read the cookie return nothing, you just need to set the expiration date to a time in the past. You should define the cookie path to ensure that you delete the right cookie. Some browsers will not let you delete a cookie if you don’t specify the path.
Q 21. Consider the following code:
function test() {
console.log(a);
console.log(foo());
var a = 1;
function foo() {
return 2;
}
}
test();
What is the result of executing this code and why?
Answer. The result of this code is undefined and 2.
The reason is that both variables and functions are hoisted but variables don’t retain any assigned value. So, at the time the variable “a” is printed, it exists in the function but it’s still undefined. Stated in other words, the code above is equivalent to the following:
function test() {
var a;
function foo() {
return 2;
}
console.log(a);
console.log(foo());
a = 1;
}
test();
Q 22. List the comparison operators supported by JavaScript?
Answer. The comparison operators are:
- < Less than
- > Greater than
- <= less than or equal to
- >= Greater than or equal to
- == Equal to
- != Not Equal to
- === Equal to with datatype check
- !== Not equal to with datatype check
Q 23. How you can clone an object in JavaScript?
Answer. Object.assign()
method is used for cloning an object in Javascript.
Syntax:
var x = {myProp: "value"};
var y = Object.assign({}, x);