Interview Questions | Front-end | 2.2 years | Preparation time 4 months
I interviewed for 30+ companies(failed in many) and finally received 3 offers :D.
I hope these interview questions would help the front-end community on Leetcode.
I also prepared for DSA from leetcode
Leetcode count - 150 easy | 150 medium | 10 hard problems.
I will post the solutions to these questions too if I get more upvotes :D
System Design for Front-end Interviews https://leetcode.com/discuss/interview-experience/2074910/System-Design-for-Front-end-Interviews
Compensation Details https://leetcode.com/discuss/compensation/2073429/Livspace-SDE-1-UI-or-Bazaar-Voice-or-Lambda-Test
Interview Questions
[1,2].duplicate(); // Should return [1,2,1,2]
$("button").addClass("change").css("background-color","yellow")Print 100 buttons with nos. and click any button to alert the number. Hint : Use the concept of event bubbling/capturing to implement this.const obj = {
A: {
B: {
C: {
D: {
E: 2,
},
},
},
},
};
console.log(read(obj, "A.B.C.D.E"));
// return 2 as answer if E exists else return undefined16.Write a method sum which gives the following output sum(2)(3).
17. Five HTTP response code used for
(function(){
var a = b = 3;
})();
console.log("a defined? " + (typeof a !== 'undefined')); // false
console.log("b defined? " + (typeof b !== 'undefined')); // trueconst KEY = 'white_rabbit';
if (true) {
const KEY = 'ginger_rabbit';
}
console.log(KEY); // white_rabbitlet x = 42;
if (true) {
console.log(x);
let x = 1337;
} <div id =”test”>
<span> Text </span>
</div>
div#test span { color: green; }
div span { color: blue; }
span { color: red; }input(obj,'key1', 'key2', 'key3'); // 10
test1.js file contains:
var a = 20;
alert(a);
alert(b);
test2.js file contains
alert(a);
var b = 20;var a = 5;
var b = '5';
if (a == b)
console.log('equal');
else console.log('not equal'); // equalconsole.log([5, 7, 7, 5, 9].reduce((a, b) => a + b, 5)); //33 + 5 = 38const items = new Set();
items.add('ball');
items.add('bat').add('shoes').add('gloves');
console.log(items.has('bat'));
items.delete('gloves');
for(const x of items){
console.log(x);
}
console.log(items.size());
items.clear();
console.log(items.size());The Tasks are passed into the board Component in the following format
{1:[task1, task2],
2:[task3, task4],}
// Print values of a
const arr =[{a:1,b:2},{a:1,c:3}];What would happen when you try to find values of b?
52.Why is useMemo used?
// url
www.google.com/?searchString=Hello+G%C3%BCnterconst Emp ={
name:"Ya",
company: "Ret"
}
const me = Object.create(Emp);
me.task = "Java";
delete me.company;// still shows the company name
console.log("uuu",me);
Output:
uuu {task: 'Java'} task: "Java"[[Prototype]]: Object company: "Ret"name: "Ya"[[Prototype]]: Object62.What are the 3 different types to create an object in JavaScript?
63. What is the difference between async and defer in javascript?
setTimeout(()=>console.log("b"), 5000);
setTimeout(()=>console.log("a"),0);
setTimeout(()=>console.log("i"));
console.log("yo");
// Prints yo, a ,i, b67.Implement in Javascript to populate template object from data object.
// Populate template from data
let data = {
name: {
first: "Ashish",
last: "Garg",
},
age: 18,
dob: "09/03/xxx",
};
let template = {
name: {
first: "",
middle: "",
last: "",
},
age: 0,
arr: [{a: "1", c: "2"}, 2, 3]
};Can you store passwords in local storage?
69.Explain what are JWT Tokens and how are they used?
Why CORS? Why the error on the client side if CORS is allowed?
Explain semantic tags in HTML.
Difference between HTML5 and HTML?
What does !DOCTYPE do
74.What would happen for this if you only have this one div
div:before {
font-size:12px;
color: #000;
background: red;
width :50px;
height: 50px;
border-radius: 50px;
}75.Why react instead of Javascript.
76. Explain Virtual Dom.
console.log(false == '0'); // true
console.log(true === '1'); // false80.What would be the order of the following children?
// HTML
<div class ='parent'>
<div class = 'child-1'>
ABC
</div>
<div class = 'child-2'>
EFG
</div>
<div class = 'child-2'>
OFD
</div>
</div>
// CSS
.parent{
display: flex;
}
.child-1{
flex: 0 0 30;
}
.child-2{
flex: 0 0 40;
float: left;
}
.child-3{
flex: 0 0 30;
}var arr1 = 'john'.split('');
var arr2 = arr1.reverse();
var arr3 = 'jones'.split('');
arr2.push(arr3);
console.log('array 1:length = '+ arr1.length + ' last = '+ arr1.slice(-1));
// Ans- array 1:length = 5 last= j,o,n,e,s
82.Write a media query to change background to red for these devices 1024px and 768px
83. Why Redux? Is Redux synchronous or asynchronous?
Write a function which returns a
flattened POJO (object) when given a nested POJO.
E.g. Input:
person: {
name: "Aditya",
age: 14,
},
info: {
medical: {
bloodGroup: "A+",
},
pets: {
dog: "bruno",
},
},
};
Output:
{
'person.name': 'Aditya',
'person.age': 14,
'info.medical.bloodGroup': 'A+',
'info.pets.dog': 'bruno'
}
Hint: Using a recursive approach might helpElements are stacked horizontally and vertically.
Elements should have equal spacing
Elements should be in scrollable layout
It should be responsive
Sidebar will stay fixed on the left.main(){
console.log(1)
sleep();
console.log(2)
}var x = 1;
var output = (function() {
delete x;
return x;
})();Some more videos that you could refer for questions
(These are super helpful & very important)
Not only these videos some of his videos about functions, map, filter and reduce and let,var and const are super helpful
I am not promoting something here.
Some of repeated DSA problems.
1 .Capitalize first letter of each word in a sentence without using string methods (Use Prototype to implement this i.e s.capitialize1()).
These resources are also super helpful
One more suggestion always document the questions with detailed answers you were asked in any interview. And keep revising them. After some interviews the questions keep repeating and it would help you in cracking them. (I followed a similar approach)
Last but not the least Akshay Saini's Youtube channel is a gem for front-end interviews.
Keep Hustling and keep interviewing. Never give up.
I will keep the post updated as I find more questions.
Thanks A Ton :)