Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views20 pages

Interview Questions

The document outlines a series of JavaScript interview questions and coding challenges from various companies, including Flock, Hotstar, Atlassian, Rapyuta Robotics, Times Internet, PostMan, Media.net, Book My Show, and Paytm. Topics covered include hoisting, event loops, promises, rendering, closures, and various coding tasks such as implementing a sum function and handling asynchronous operations. Additionally, it discusses concepts related to React, browser rendering, and performance optimization techniques.

Uploaded by

agmaya100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views20 pages

Interview Questions

The document outlines a series of JavaScript interview questions and coding challenges from various companies, including Flock, Hotstar, Atlassian, Rapyuta Robotics, Times Internet, PostMan, Media.net, Book My Show, and Paytm. Topics covered include hoisting, event loops, promises, rendering, closures, and various coding tasks such as implementing a sum function and handling asynchronous operations. Additionally, it discusses concepts related to React, browser rendering, and performance optimization techniques.

Uploaded by

agmaya100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Js Interview Question

Flock

Round 1
1. Hoisting Understanding Hoisting in JavaScript
2. Call apply bind pollyfill of bind
3. event loop wrt to set time out
4. Promise.all and it's pollyfill
5. Box model
6. Multiple inheritance
7. Super call to parent in inheritance
8. Cookies vs local storage
9. Workers a bit
10. Reduce and it's pollyfill
11. Browser rendering and reflow
12. Promise then then vs settimeout

Round 2
Create sum function which do the following

Sum(1) // 1
Sum(2) // 3
Sum(30) // 33
Promise class implementation

Hotstar - someone else gave this one

Round 1
1. function a () {
var one = 'one'

function b () {
var one = 'two'
c()
}

function c() {
console.log(one)
}
b()
}

a()

2. If we write link tag for css and after write script tag in head than how rendering we progress
Pair of given sum in an array

Atlassian

First Round

Rendering related things and what happens when script is added before body and at last in the
body
getElementById is good thing to use or not
https://github.com/abhishekthakurak/atlassianInterview implement this #private repo

Second Round
Discussed about projects (How you allow update and manage future changes in this repo)
What you do before choosing frameworks
What you do other than just using load time etc for better performance (memory leak - Heap
snapshots)
Promise.all polyfill
Let var and const (hoisting word should imp)
Webpage security (something related to cross site scripting)
Static Typing
What things I should have ask you in this interview

Third Round - Managerial Round

Discuss about projects


Why you want to change the company
Negative feedback that you receive
Any feedback you gave to your manager

Fourth Round - Values Round


Discussed their company values

Rapyuta Robotics

First Round
1. Async vs Defer
2. Why we need graphql
3. React Component which will show count 0 to 10 using setInterval
(https://codesandbox.io/s/pedantic-boyd-176xh?file=/src/App.js) idk how long this link will be
available
Optimization related questions
First meaningful paint vs first contentful paint vs Cpu idle time

Second Round

Optimization questions
How this will work (http://koalastothemax.com/) this is depiction of
http://koalastothemax.com/img/koalas1.jpg (how this is rendered, how color get changed and
calculated, what will you do if we have some other component beside this as this much number
of dom element will affect other dom element also), where to put a listener in this
How float is different from absolute and fixed
How to detect memory leak
Type error vs reference error
What are websockets
Live loading vs hot loading
How Http works

Third Round
SetInterval using SetTimeout
Different time libraries - https://blog.cloudflare.com/browser-performance-api/
Calculate how much time is taken by getElementById without using Date.now()
Implement a function move(element,position,duration) {...} which moves the element from an x
to position in the given duration (complicated question)
For above question how will you replace setTimeInterval with for better performance

Times Internet

Write the below function

var c = counter();
console.log('c', c)
c.add(5);
c.add(9);
c.retrieve() // 14

function counter () {
let total = 0;
return {
add (a) {
total += a;
},
retrieve () {
return total;
}
}
}
/****/

var employee = { company: 'xyz'}


var emp1 = Object.create(employee);
// var emp1 = Object.assign({}, employee); // if this uncommented so output is undefined

delete emp1.company;
console.log(emp1.company); // output is 'xyz'

/****/

Output

sayName()// type error


sayAnotherName()
var sayName = () => console.log("Hello")
function sayAnotherName() { console.log("World") }

/***/

Output
function Person(name) {
this.name = name;
}
Person.prototype.getName = () => {
return this.name;
};
const tom = new Person('Tom');
console.log(tom.getName()); // will give an error
/*****/

Align child to center without using flex

<div class="parent">
<div class="child"></div>
</div>

<style>
.parent {
width: 500px;
height: 500px;
}
.child {
Margin: auto;
width: 100px;
height: 100px;
}
</style>

* better *

.parent {
width: 500px;
height: 500px;
position: relative;
}
.child {
width: 100px;
height: 100px;

margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

/***/
Anagrams - abc, bac, bca

Given an input string find out no. of pairs of anagrams present in it.
input -> abba
output -> 4 ([a, a], [b,b], [ab, ba], [abb, bba])

Second Round

<div class='parent'>
<div class='a common'>A</div>
<div class='b common'>B</div>
<div class='c common'>C</div>
</div>

Print like below

A
B
C

*******

Print like below


ABC

*****************************
<div class='parent'>
<span class='a common'>A</span>
<span class='b common'>B</span>
<span class='c common'>C</span>
</div>

Print like below

A B C

Given:
Width of parent = 300px
Width of each child = 100px
background -color = diff for each

*******
What is the display property on span

*******

Difference between inline block and block

*****************************
Throttle vs Debounce difference create any one of them
*****************************
Why to use react
*****************************
Synthetic events
*****************************
How react knows to run reconciliation
**********
Why react needs key for array property

PostMan
Round 0 - Telephonic

About the projects - deep understanding


Browser Rendering
Why to use react(VDOm, how it works, how react knows to change something, what are things
react won’t do easily on its own)
Events (delegation, synthetic events)
How to construct a modal using css (I also told about portal)
Web page security, Xss attacks and all

Media.net - Round 1

Closure, give examples of Closure, write the same example without using closure
Prototype inheritance
Why to use react wrt to vanilla
Is react two way binding or one way binding
You have to write two way binding framework how you will right
Infinite scroll how to implement ( if you are managing with specific list items then if you change
data that is shown to user then also it might get expensive how you do that)
If you have 1000 inputs how you bind its data model efficiently
Book my show

Round 0 - screening normal discussion what i do and what they do - how web page get
rendered etc

Round 1
Assignment - hacker rank - js/html and css questions

Round 2
Extend the assignment questions
Questions related to projects
Regex related questions
Question related to Service workers

Round 3
This, reduce polyfill, closure
React hooks comparison to classical thing
React Fibre details
Event loop
Why to use redux in comparison of context api

Css question

A B C takes whole of the window and we have horizontal scroll after that and break line after F

ABCDEF
GH
SSR

Round 4
You have an array and a value k you have to find max sum of k consecutive element
Example - 3, 4, 5, 8, 12, 0 , 4, 2
K=3
5 + 8 + 12 = 25 is the answer
Given a binary tree you have to find if it is a BST
For Quicksort what mechanism we can use for partition array so as this algo will always give
O(nlgn)
HotStar
sum(1, 2, 3, …) question, sum(1)(2)(3, 4, 5)() currying question
What is this, inheritance, object.freeze, object.seize
Deep clone polyfill and we can have cyclic object as well
Scope chaining, data shadowing and hoisting
Let and const are hoisted or not

---------------------------------------------- HITESH ---------------------------------------------


FLock ROund - 1
Event loop
Closure
Throttle / debounce
Web worker / service worker
Xss
Cors
Web page optimisation
Super in react
HOC
VDOM
State vs props
React hooks
React fibre
Pre git hooks
Local storage / session storage / cookie / indexdb
Promise.all polyfill
Bind polyfill
SetInterval using SetTimeout
Life cycle hooks

--------------------------------------------------------
function abc(){
setTimeout(()=>{
console.log("set time out")
},0)
console.log("hey")
}
abc() ;

--------------------------------------------------------
function abc(){
setTimeout(()=>{
console.log("set time out")
},0)
Promise.resolve("promise resolved").then(res => console.log(res))
}

--------------------------------------------------------
function abc(){
for(var i=0;i<5;i++){
setTimeout(function(){
console.log(i)
}, 500)
}
}
abc()

-------------------------------------------------------
var name = 'ruhi'
var a = {
name: "rohan",
printName: () => {
console.log(this.name)
}
}
a.printName()

--------------------------------------------------------
function deepCopy (obj) {
const res = {}
const keys = Object.keys(obj)

keys.forEach(key => {
if (typeof obj[key] === 'object') {
res[key] = deepCopy(obj[key])
} else {
res[key] = obj[key]
}
})
return res
}
var abc = {
name: 'john',
age: 20,
address: {
city: 'bangalore',
state: 'tamilnadu',
street: {
pincode: 11111,
houseno: 234
}
}
}
--------------------------------------------------------
0.1 + 0.2 !== 0.3
--------------------------------------------------------
add(1)(2)(3) // 6
add(1,2,3) //6
add(1,2)(3,4)(5) // 15

function add() {
// 1,2
let sum = 0
const args = Array.prototype.slice.call(arguments)
if (args.length > 0) {
args.forEach(val => sum += val)
}

myAdd.value = sum
function myAdd() {
const args = Array.prototype.slice.call(arguments)
if (args.length > 0) {
args.forEach(val => myAdd.value += val)
}
return myAdd
}
return myAdd
}

console.log(add(1,2)(3)(4,5,6)().value)

TIMES Round 2-
<div class='parent'>
<div class='a common'>A</div>
<div class='b common'>B</div>
<div class='c common'>C</div>
</div>
Print like this
A
B
C

Print like this => ABC

.common {
display: inline;
}

*****************************

<div class='parent'>
<span class='a common'>A</span>
<span class='b common'>B</span>
<span class='c common'>C</span>
</div>
A B C
Given:
Width of parent = 300px
Width of each child = 100px
.common {
display: inline-block;
}

*****************************
Throttle vs Debounce

function throttle(fn, limit) {


let lastFn
let lastRunTime
return function () {
const ctx = this
const args = Array.prototype.slice.call(arguments)
if(!lastFn) {
fn.apply(ctx, args)
lastRunTime = Date.now()
} else {
clearTimeout(lastFn)
lastFn = setTimeout(function() {
fn.call(ctx, args)
lastRunTime = Date.now()
}, limit - Date.now() - lastRunTime)
}
}
}
*****************************
function sum (x, y, z){
return x+y+z
}

curry(sum) => curriedFn

curriedFn(10, 20, 30) => 60


curriedFn(10, 20)(30) => 60
curriedFn(10)(20)(30) => 60
curriedFn(10)(20)(30) => 100

Implement curry

function curry(fn) {
// noOfArgs required by fn
const args = []
const ctx = this
function curr() {
const currentArgs = Array.prototype.slice.call(arguments)
args.push(...currentArgs)
if (noOfArgs === args.length) {
return fn.apply(this, args)
}
return curr
}
if (noOfArgs === args.length) {
return fn.apply(this, args)
}
return curr
}

*****************************

Rapyuta + Unacademy + wheelseye ->

Why to use emotion.js


useSelector polyfill
Connect polyfill
What is ETag
Webp vs JPEG vs PNG
React vs React Native vs Native android / ios app - when to write which one
Sockets vs http - how these work, underlying protocol
What is data encoding Base 64/ utf-8 charset / utf-16 charset
Indexed db
Web hooks

HTML5 - benefits of new html5 tags - (accessibility, context for seo, better seo)
Color coding hash values - is it only 6(XXXXXX) long or anything else
How encryption works in HTTPS
How to setup HTTPS certificates
XML vx JSON vs YML

Virtual dom 1 vs virtual dom 2


Why do we keep 2 virtual doms / why not compare v1 directly with original dom
Benefits of synthetic events

How to do animations on canvas


How animations work
Create ease in or ease out animation on canvas
Pub sub implementation
Create a middleware which listens to socket connection and calls all subscribers on every
message received as per instructions in message

Bst
Tree traversals
Bst validation
Min heap
Max heap
Priority queue
Binary tree
Binary tree me kai bst ho sakte hai unme se jiska sum max hai wo nikalo

Map polyfill using reduce


console.log((New Array(5)).map((_, i) => i+1))

Paytm
Round 1

After intro
They ask to give rating on css html js and react then ask questions according to that

Ds
0,1 sort

Javascript
1. Pollyfill of object.freeze
2. Create set using array and add funcions like add remove
Intersection union difference values

Html css
Doctype, box model , different types position and there meaning
Async defer when and why to use, span vs div

React
Hooks full lifecycle
Ssr
Hydrate vs render
Rendertonodestream (streaming)
Paytm second round
Mostly related to resume things
1. Performance, webpack
2. Differential serving
3. Service worker

Paytm 3 Round (Managerial Round)

1. How to do chunking
2. How to improve performance
3. Tree Shaking
4. How Service Workers Helps Us
5. How to set up service Worker
6. How to load data just like twitter suppose there are 10 listings which are visible add 2 more
latest updates
7. Features of PWA (progressive web app)
8. WebSockets

Stanza living 1 round


1. How browser works full details
2. Async vs defer
3. React hooks how to do things similar to didmount and unmount
4. Use effect related things
5. Connect - how state being get in matchstatetoprops
6. Different params other than match state to props and match dispatch to props

Stanza living second round


1. Project related things
2. Sum(1,2)(3,4)(5)(6) curry question

Stanza living 3 round with EM

1.How login works with multiple user privellages


2. What are secure cookies
3. When to use cookies, local storage, session storage
4. There is an array 1-n but 1 number is missing in that array and one got repeated please tell
which number is Missing
5. How react native update apps by js push

Hive.ai first round


https://docs.google.com/forms/d/e/1FAIpQLSfo5ZYrOC8_k2KHrx-6--
B5j8flHARQUbucm4jF1MtqcfY4nA/viewform?edit_requested=true

1. Draw ace of spade card should be responsive


2. Reverse a string but should not change any special characters
3. Create a button when you click it will call and api mock function which will fail or pass

If pass then chanhe button text to finish


If fail set text to retrying in x second where x is initial timer given by user
And after that it will rerun that api mock if it again fails than run the method again but with
double time and do this until it reaches maxtimelimit or get passed.
If max timelimit reached reset the button status and repeat the process

Hive.ai 2 round

1. 10 ways you can improve performance

answer =>

bundling based on entry points


Manging bundling of packages
Lazy load
Load css only when component loaded
Image compression (brotli)
Minification and uglification
Try to build in house packages
Service workers - PWA
Full page caching --
Differential serving
Tree shaking

2. explain Full page caching


3.
create CreateBase
var addSix = createBase(6);
addSix(10); // returns 16
addSix(21); // returns 27

var addFive = createBase(5);


addFive(11) // 16

4. addition(6,1,2,3,4)(1)(23, 5,6, 7)....(1).end(); // create addition method


5.
Create appropriate Data Structure in javascript to handle the following:
(data structure example: Objects, functions, arrays, classes)
- Create a Card with Card Types: Spade/Diamond/Club/Heart
- Create a deck of cards ( with total 52 cards , 13 of each type OR 104 cards with 26 of each
type OR 156 cards with 39 of each type)
- Should be able to shuffle a deck of cards
- Should be able to merge two deck of cards
- Should be able to shuffle merged deck of cards
- Should be able to list out indices of a particular Card Type in the shuffled deck of cards.
6. create

componentDidMount
componentWillUnmount

using hooks
7. explain lifecycle of react component

Zomato First Round 1

1. Array Map polyfill


2. _.get unserscore get polyfill simple one (only object things not array)
3. Array.flatArray polyfill
4. what are pure Functions
5. web page optimizations related things

Zomato round 2
1. How build works in your company how deploy works and how you serve the code to user
2. Redux subscibe polyfill
3. How server side rendering actually works
4. If you have /ncr/abc or /ncr/any-arbitory-param how these nested routes works with server
side rendering

Vedantu Round 1

1. Closure
2. Splice related questions
3. Sort an array descending ascending
4. How redux has pure function reducer
5. React lifecycle detailed
6. GitHub profile page bnane ko kaha react redux css mai 1.5 gante mai ek portion bnana tha
Vedantu 2 round

1. How painting works , and how z index being placed


2. How you optimize image and what are progressive images
3. Can we have class component within a functional components and vice a versa
4. How to check profiler and performance in debug tab
5. Promises and what are the things that are handled with microtask queue
6. Tree shaking
7. Request animation frame
8. Performance related questions
9. Currying question
10. Debounce vs throttle
11. How can we use debounce with refs only this was toughest questions I got
12. Create a box and have 3 boxes diagonally placed inside that box
13. How can we optimize react related things

Cars24 round 1

1. React hooks
2. Build related things as per intro discussion

Aur khas dyan nhi ara but kuch khas nhi pucha kafi basic tha

Cars24 Round 2
Cto round only Bakr happened

Cure fit Round 1


1. Performance
2. How browser cache things
3. React vs React Dom
4. async vs defer
5. How browser works
6. Why to use hooks
7. Why to use redux
8. When to use redux
9. How to optimize images
10. create add(1)(2)(3)()
11. setTimer([4000, 2000, 7000, 3000], 0) // create a method to run interval based on array
values (like for 4000 run timer 4000, 3000, 2000, 1000 then pick second index and run this for
second index

You might also like