Back to articles
Maching Coding Question for Interview

Maching Coding Question for Interview

via Dev.to JavaScriptKush Bhandari

Interview can ask you to create a To-do List with the help on Html and Javascript only without use of React. In this case the knowledge of Event bubbling, Event delegation is must. Event Bubbling : Event bubbles from child to parent. Event Capturing : Event Capturing from parent to child. document.addEventlistener("click",handleClick,true); If we pass true in this event capturing will happen. and false will cause the bubbling. Now, Where this find useful: Suppose you have 3 div nested one another making child div , parent div, grand parent div. If we attach a console.log() on every div. So in event bubbling we will get the child console.log first and then parent and so on. vice versa with event capturing. Now, what is event delegation: So, Instead of attaching individual event listener to a list of item, we attach a common event listener to the list and handle every list item click. Advantages of Event Delegation: Code reuse. Code Simplification. Disadvantages: Some event doen't get pr

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
2 views

Related Articles