SlideShare a Scribd company logo
1 of 7
DOM & Events
Document Object Model, Event Loop, Event Bubbling &
Events
Event Loop
• JS Engine executes JS in a single threaded way.
• Fakes Concurrency
• What if we write some code that blocks the flow ?
console.log(“Javascript UI/UX Session");
function a(x){
console.log(“Starting for a()");
b(x);
console.log(“Ending of a()");
}
function b(y){
console.log(“Starting of b()");
console.log("value passed is " +y);
console.log(“Ending of b()");
}
console.log("Start");
a(45);
console.log("End");
Event Table & Event Queue
• Any callback(async) function in the code will be added to Event Table.
• Function register itself in Event Table & will wait for the expected event to
happen.
• Once event happens Event Table will move the function to Event Queue.
• Event Queue is a staging area, this will move function back to Execution.
DOM
Methods to access DOM
• Finding Elements
• Changing Elements
• Adding or Removing Elements
Questions???

More Related Content

What's hot

From rest api to graph ql a 10 year journey
From rest api to graph ql a 10 year journeyFrom rest api to graph ql a 10 year journey
From rest api to graph ql a 10 year journeyArno Schulz
 
Perl Tools for Productivity
Perl Tools for ProductivityPerl Tools for Productivity
Perl Tools for ProductivityTudor Constantin
 
RxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScriptRxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScriptViliam Elischer
 
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6Temporal Performance Modelling of Serverless Computing Platforms - WoSC6
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6Nima Mahmoudi
 
老派浪漫:用 Kotlin 寫 Command Line 工具
老派浪漫:用 Kotlin 寫 Command Line 工具老派浪漫:用 Kotlin 寫 Command Line 工具
老派浪漫:用 Kotlin 寫 Command Line 工具Shengyou Fan
 
Google Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScriptGoogle Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScriptOmar Miatello
 
Falling into that State (of) Flow: Easy State Management
Falling into that State (of) Flow: Easy State ManagementFalling into that State (of) Flow: Easy State Management
Falling into that State (of) Flow: Easy State ManagementTony Kazanjian
 
RedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedis Labs
 
[JCConf 2017] Reactive Programming with Reactor
[JCConf 2017] Reactive Programming with Reactor[JCConf 2017] Reactive Programming with Reactor
[JCConf 2017] Reactive Programming with ReactorSwanky Hsiao
 
用 Kotlin 做自動化工具
用 Kotlin 做自動化工具用 Kotlin 做自動化工具
用 Kotlin 做自動化工具Shengyou Fan
 
10 minute command line apps with zio cli
10 minute command line apps with zio cli10 minute command line apps with zio cli
10 minute command line apps with zio cliAiswarya Prakasan
 
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)GreeceJS
 
Cycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI frameworkCycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI frameworkNikos Kalogridis
 

What's hot (20)

From rest api to graph ql a 10 year journey
From rest api to graph ql a 10 year journeyFrom rest api to graph ql a 10 year journey
From rest api to graph ql a 10 year journey
 
Perl Tools for Productivity
Perl Tools for ProductivityPerl Tools for Productivity
Perl Tools for Productivity
 
RxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScriptRxJS - The Reactive Extensions for JavaScript
RxJS - The Reactive Extensions for JavaScript
 
Airflow introduction
Airflow introductionAirflow introduction
Airflow introduction
 
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6Temporal Performance Modelling of Serverless Computing Platforms - WoSC6
Temporal Performance Modelling of Serverless Computing Platforms - WoSC6
 
老派浪漫:用 Kotlin 寫 Command Line 工具
老派浪漫:用 Kotlin 寫 Command Line 工具老派浪漫:用 Kotlin 寫 Command Line 工具
老派浪漫:用 Kotlin 寫 Command Line 工具
 
Google Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScriptGoogle Cloud Functions: try { Kotlin } instead of JavaScript
Google Cloud Functions: try { Kotlin } instead of JavaScript
 
RedisGears
RedisGearsRedisGears
RedisGears
 
Falling into that State (of) Flow: Easy State Management
Falling into that State (of) Flow: Easy State ManagementFalling into that State (of) Flow: Easy State Management
Falling into that State (of) Flow: Easy State Management
 
Jetpack joyride!
Jetpack joyride!Jetpack joyride!
Jetpack joyride!
 
RedisGears: Meir Shpilraien
RedisGears: Meir ShpilraienRedisGears: Meir Shpilraien
RedisGears: Meir Shpilraien
 
Apache Airflow overview
Apache Airflow overviewApache Airflow overview
Apache Airflow overview
 
React meets o OCalm
React meets o OCalmReact meets o OCalm
React meets o OCalm
 
MLBlock
MLBlockMLBlock
MLBlock
 
[JCConf 2017] Reactive Programming with Reactor
[JCConf 2017] Reactive Programming with Reactor[JCConf 2017] Reactive Programming with Reactor
[JCConf 2017] Reactive Programming with Reactor
 
用 Kotlin 做自動化工具
用 Kotlin 做自動化工具用 Kotlin 做自動化工具
用 Kotlin 做自動化工具
 
10 minute command line apps with zio cli
10 minute command line apps with zio cli10 minute command line apps with zio cli
10 minute command line apps with zio cli
 
Cheep microservices
Cheep microservicesCheep microservices
Cheep microservices
 
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
 
Cycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI frameworkCycle.js - A functional reactive UI framework
Cycle.js - A functional reactive UI framework
 

Similar to DOM & Events

History of asynchronous in .NET
History of asynchronous in .NETHistory of asynchronous in .NET
History of asynchronous in .NETMarcin Tyborowski
 
Mastering Azure Functions
Mastering Azure FunctionsMastering Azure Functions
Mastering Azure FunctionsBob German
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsNodeXperts
 
UML for Aspect Oriented Design
UML for Aspect Oriented DesignUML for Aspect Oriented Design
UML for Aspect Oriented DesignEdison Lascano
 
JavaScript Async for Effortless UX
JavaScript Async for Effortless UXJavaScript Async for Effortless UX
JavaScript Async for Effortless UX재석 강
 
Fluentd - CNCF Paris
Fluentd - CNCF ParisFluentd - CNCF Paris
Fluentd - CNCF ParisHorgix
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chhom Karath
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade ServerlessKatyShimizu
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade ServerlessKatyShimizu
 
Khan Academy Computer Science
Khan Academy Computer ScienceKhan Academy Computer Science
Khan Academy Computer Sciencejeresig
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
Introduction to Programming Bots
Introduction to Programming BotsIntroduction to Programming Bots
Introduction to Programming BotsDmitri Nesteruk
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsGary Yeh
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsMike Hagedorn
 
How NOT to write in Node.js
How NOT to write in Node.jsHow NOT to write in Node.js
How NOT to write in Node.jsPiotr Pelczar
 

Similar to DOM & Events (20)

History of asynchronous in .NET
History of asynchronous in .NETHistory of asynchronous in .NET
History of asynchronous in .NET
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
 
Developing Async Sense
Developing Async SenseDeveloping Async Sense
Developing Async Sense
 
Mastering Azure Functions
Mastering Azure FunctionsMastering Azure Functions
Mastering Azure Functions
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
UML for Aspect Oriented Design
UML for Aspect Oriented DesignUML for Aspect Oriented Design
UML for Aspect Oriented Design
 
JavaScript Async for Effortless UX
JavaScript Async for Effortless UXJavaScript Async for Effortless UX
JavaScript Async for Effortless UX
 
Fluentd - CNCF Paris
Fluentd - CNCF ParisFluentd - CNCF Paris
Fluentd - CNCF Paris
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
 
[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless[NDC 2019] Enterprise-Grade Serverless
[NDC 2019] Enterprise-Grade Serverless
 
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
[NDC 2019] Functions 2.0: Enterprise-Grade Serverless
 
Khan Academy Computer Science
Khan Academy Computer ScienceKhan Academy Computer Science
Khan Academy Computer Science
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
Introduction to Programming Bots
Introduction to Programming BotsIntroduction to Programming Bots
Introduction to Programming Bots
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
 
Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure
 
Playing With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.jsPlaying With Fire - An Introduction to Node.js
Playing With Fire - An Introduction to Node.js
 
NodeJS
NodeJSNodeJS
NodeJS
 
How NOT to write in Node.js
How NOT to write in Node.jsHow NOT to write in Node.js
How NOT to write in Node.js
 

DOM & Events

  • 1. DOM & Events Document Object Model, Event Loop, Event Bubbling & Events
  • 2. Event Loop • JS Engine executes JS in a single threaded way. • Fakes Concurrency • What if we write some code that blocks the flow ?
  • 3. console.log(“Javascript UI/UX Session"); function a(x){ console.log(“Starting for a()"); b(x); console.log(“Ending of a()"); } function b(y){ console.log(“Starting of b()"); console.log("value passed is " +y); console.log(“Ending of b()"); } console.log("Start"); a(45); console.log("End");
  • 4. Event Table & Event Queue • Any callback(async) function in the code will be added to Event Table. • Function register itself in Event Table & will wait for the expected event to happen. • Once event happens Event Table will move the function to Event Queue. • Event Queue is a staging area, this will move function back to Execution.
  • 5. DOM
  • 6. Methods to access DOM • Finding Elements • Changing Elements • Adding or Removing Elements