Javascript Interview Topics

1. What is the difference between == and === ?

Double equal (==) : converts both the operands to the same type and then compares

Example :

console.log( 2 == ‘2’) ; // true

Triple equal(===) : Does not convert to same type


Console.log( 2 === 2 ) // false

2. WHAT IS THE VALUE OF 5+6+8+”7"?

The expected output is 197. Since 5,6, and 2 are integers, they will be added numerically. And “7” is a string, its concatenation will be done.

3. What is truthy and falsy values?

Truthy values : There are certain values in Javascript that return true when converted into boolean. Such values are called truthy values.

“false” , “0”, {} (empty object) , & (empty array)

Falsy values: On the other hand there are certain values that return false when coerced to boolean. These values are known as falsy values.

false , 0 , “ ” (empty string) , null, undefined , & NaN

4. Ways to create a variable

There are 3 ways to create a variable in javascript. Var,let and const. Variables created with var are in scope of function (or global if declared in the global scope); let variables are block scoped ; and const variables are like plus their values cannot be reassigned.

Example :

var x = “some value”; //functional or global scopedLet y= “some value”; //block scopedConst z = “some value”; //block scoped + cannot get new value

5. What is Scope?

Scoping is an important topic in JavaScript .Scope in js is an area where you can access or use your declared variables/functions. For private a variable or function or access a variable from all places and how or where to declare it, all discuss this within scoping.

There are two main types of scoping in JavaScript: Global Scope and Local Scope,

6. What is DOM ?

The Document Object Model (DOM) is a programming interface for HTML and XML documents. The Document Object Model (DOM) represents that same document so it can be manipulated. The DOM is an object-oriented representation of the web page, which can be modified with a scripting language such as Javascript.


I will check for whitespace and walk through the string. I will also check there multiple white-spaces are present or not. after that, I will reverse the string.

var string = “Welcome to this Blog!”;var reverseEntireSentence = reverseBySeparator(string, “”);// Output becomes !golB siht ot emocleWvar reverseEachWord = reverseBySeparator(reverseEntireSentence, “ “);// Output becomes emocleW ot siht tpircsavaJ !golBfunction reverseBySeparator(string, separator) {return string.split(separator).reverse().join(separator);}

8. Find the largest element in an array javascript

function megaFriend(nameOfFriends) {if (nameOfFriends.length > 0) {var bigName = nameOfFriends[0].length;for (var i = 0; i < nameOfFriends.length; i++) {if (bigName < nameOfFriends[i].length) {var megaName = nameOfFriends[i];}}}else {return ‘this array is empty’;}return megaName;}var nameOfFriends = [‘haris’, ‘tushar’, ‘shakib’, ‘mashrafee’, ‘riad’];bigFriend = megaFriend(nameOfFriends);console.log(bigFriend);//Expected output : mashrafee

9. Generate a random number between 1 to 100 ? The number should be an integer.

const randomNumber = 1 + Math.floor(Math.random() * 100);console.log(randomNumber);

10. Create a Fibonacci Series using a for loop

Fibonacci series is defined as a sequence of numbers in which the first two numbers are 1 and 1, or 0 and 1, depending on the selected beginning point of the sequence, and each subsequent number is the sum of the previous two numbers.

function getFibonacci(n){const fibo = [0,1]for (let i =2; i<=n; i++ ) {fibo [i] = fibo[i -1] + fibo [i -2];}return fibo[n];}console.log ( getFibonacci(9)) //output : 34




Junior Web Developer

Love podcasts or audiobooks? Learn on the go with our new app.

تحسينات على أداء مشروع تريدبوك

Actually blogging with Clojure

Important Topics in

JS got some love but it deserves much more

More efforts w

A Guide to Next.js API Routes

Optimize the Dockerfile in your Node.js TypeScript Project

Write beautiful and Elegant Javascript code with short-circuit evaluation.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shajjad Abir

Shajjad Abir

Junior Web Developer

More from Medium

TechTogether Miami — Achievement Unlocked: First Hackathon

Dev Updates: January

2124. Check if All A’s Appears Before All B’

Learning about fetch() in my first JavaScript program…