Skip to content

Instantly share code, notes, and snippets.

@Roshankrsoni
Last active July 16, 2022 06:26
Show Gist options
  • Select an option

  • Save Roshankrsoni/3deffa545b28c8486dc17188ac2f57da to your computer and use it in GitHub Desktop.

Select an option

Save Roshankrsoni/3deffa545b28c8486dc17188ac2f57da to your computer and use it in GitHub Desktop.
Frontend/React Interview Questions
1. What are sementic tags in Html?tell some html5 tags
2. Explain the this keyword with arrow function and normal function.
-> // Arrow Function Normal Function
// SOLUTION
let user = {
name: "GFG",
gfg1:() => {
console.log("hello " + this.name); // no 'this' binding here
},
gfg2(){
console.log("Welcome to " + this.name); // 'this' binding works here
}
};
user.gfg1();
user.gfg2();
3. Write a Program
Input-> searchBoxKey
output-> search_Box_Key
// SOLUTION
-> let str5 = 'searchBoxKey';
str5.split(/(?=[A-Z])/).join('_')
4. Count the duplicate element in arrray
-> input = ['a','b','c','d','d','e','a','b','c','f','g','h','h','h','e','a'];
output - { a: 3, b: 2, c: 2, d: 2, e: 2, f: 1, g: 1, h: 3 }
// SOLUTION
function uniqueCount(arr){
let counter = {}
arr.forEach((val)=>{
counter[val] = (counter[val] || 0) + 1
})
return counter
}
5. What is event bubbling? How can we prevent it?
6. Debouncing -> code
7. Uses of Hooks and refs
8. controlled & uncontrolled component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment