SlideShare a Scribd company logo
1 of 10
Download to read offline
L E T S S E E W H A T S B E H I N D T H E
S C E N E S
PROGRAMMING | JAVASCRIPT
In the browser, we have a Javascript engine that takes the code and executes it. Each browser has its own
javascript engine Google Chrome has a V8 engine, Firefox has Spider Monkey and Safari has a Nitro engine, so
every browser will have a JS engine
Inside the engine the first step is to parse the code by a parser, it will read the code line by line and will check that
the syntax is correct. The parser will know rules for JS to ensure this. If it finds any mistakes it will throw an error
and execution will stop
Stuff happening behind the scenes
If everything is correct the parser will produce a data structure which is called Abstract Syntax Tree and that is then
turned into machine code, machine code is executed directly by the computer’s processor and that is where our
code runs. They are subtle differences about in the steps but these are the main steps for all
Stuff happening behind the scenes
The execution context is the environment in which Javascript is executed. Think of execution contexts like a box
which contains variables and our code
when we talk about JavaScript code execution, we need to keep in mind the execution stack and scope
All the code that is not inside any function is in GEC. So any variables or functions, not inside the function is in GEC.
GEC is an object which in case of a browser it will be a window object, everything you declare in a global context will be
attached to the window object
Execution Contexts
Global Execution Context (GEC)
A stack data structure in which the new execution context is pushed on top of Global Execution Context. If inside the
new execution context(which is a function basically) a new function is called it will create a new execution context and
that new execution context is pushed on top of the previous execution context
The global context is located in the first position from bottom to top in the execution stack. Every time a new context is
created when a function is called, this placed at the top of the queue. Once it's executed, they are eliminated from top
to bottom
Execution Stack
Argument object is created, which stores all arguments (if any) in a function.
The code is scanned for function and variable declarations and creates a property in the variable object (VO) that
points to those functions and variables before execution. This process is known as hoisting
Creation of the variable object
Elevate functions and variables by making them available before execution, albeit in different ways:
• Functions: only those that are declared. It makes them fully available.
• Variables: makes them available but as undefined
Hoisting
Scoping is where can the variable be accessed. Each function has its own scoping space where the variables
are defined. Typically a scope is created by if for blocks but not in Javascript. New scope is created by only
writing new functions. In Javascript we also have lexical scoping for example a function inside another function will
access to its outer function
Scoping and Scope Chain
Each and every new execution context gets a this variable. In a regular function call “this” keyword points to
window or browser object which is a global object. Important thing to remember is that the this keyword is
not assigned a value until a function where a function where it is defined is called
Scope Chain
“this” variable
As the flow of execution is followed, a chain of scopes belonging to the object variable is created to finally create the
context object
The execution stack is how the function calls are placed inside the execution stack, storing their context,
while the scope chain refers to the scope of accessibility existing between the different contexts
Remember !
In this way, the context object is created and goes to the
second phase, which is the line-by-line execution of the
code within each context until each function call ends and
they are removed from the execution stack
Conclusion
Thank you
VIBHOR GROVER

More Related Content

What's hot

Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
Adhoura Academy
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 

What's hot (20)

JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
JavaScript Tutorial For Beginners | JavaScript Training | JavaScript Programm...
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Java script
Java scriptJava script
Java script
 
Javascript
JavascriptJavascript
Javascript
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Javascript
JavascriptJavascript
Javascript
 
Java script
Java scriptJava script
Java script
 
Js ppt
Js pptJs ppt
Js ppt
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
HTML presentation for beginners
HTML presentation for beginnersHTML presentation for beginners
HTML presentation for beginners
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
CSS for Beginners
CSS for BeginnersCSS for Beginners
CSS for Beginners
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 

Similar to Javascript

Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
ch samaram
 
Memento Pattern Implementation
Memento Pattern ImplementationMemento Pattern Implementation
Memento Pattern Implementation
Steve Widom
 
Concurrency and Thread-Safe Data Processing in Background Tasks
Concurrency and Thread-Safe Data Processing in Background TasksConcurrency and Thread-Safe Data Processing in Background Tasks
Concurrency and Thread-Safe Data Processing in Background Tasks
WO Community
 

Similar to Javascript (20)

Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
[2015/2016] JavaScript
[2015/2016] JavaScript[2015/2016] JavaScript
[2015/2016] JavaScript
 
Javascripts hidden treasures BY - https://geekyants.com/
Javascripts hidden treasures            BY  -  https://geekyants.com/Javascripts hidden treasures            BY  -  https://geekyants.com/
Javascripts hidden treasures BY - https://geekyants.com/
 
Javascript internals
Javascript internalsJavascript internals
Javascript internals
 
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
 
React native
React nativeReact native
React native
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Effective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjectsEffective JavaFX architecture with FxObjects
Effective JavaFX architecture with FxObjects
 
Wwf
WwfWwf
Wwf
 
Javascript Workshop
Javascript WorkshopJavascript Workshop
Javascript Workshop
 
Workflow as code with Azure Durable Functions
Workflow as code with Azure Durable FunctionsWorkflow as code with Azure Durable Functions
Workflow as code with Azure Durable Functions
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
 
Architecture
ArchitectureArchitecture
Architecture
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Drilling the Async Library
Drilling the Async LibraryDrilling the Async Library
Drilling the Async Library
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Memento Pattern Implementation
Memento Pattern ImplementationMemento Pattern Implementation
Memento Pattern Implementation
 
Concurrency and Thread-Safe Data Processing in Background Tasks
Concurrency and Thread-Safe Data Processing in Background TasksConcurrency and Thread-Safe Data Processing in Background Tasks
Concurrency and Thread-Safe Data Processing in Background Tasks
 

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 

Javascript

  • 1. L E T S S E E W H A T S B E H I N D T H E S C E N E S PROGRAMMING | JAVASCRIPT
  • 2. In the browser, we have a Javascript engine that takes the code and executes it. Each browser has its own javascript engine Google Chrome has a V8 engine, Firefox has Spider Monkey and Safari has a Nitro engine, so every browser will have a JS engine Inside the engine the first step is to parse the code by a parser, it will read the code line by line and will check that the syntax is correct. The parser will know rules for JS to ensure this. If it finds any mistakes it will throw an error and execution will stop Stuff happening behind the scenes
  • 3. If everything is correct the parser will produce a data structure which is called Abstract Syntax Tree and that is then turned into machine code, machine code is executed directly by the computer’s processor and that is where our code runs. They are subtle differences about in the steps but these are the main steps for all Stuff happening behind the scenes
  • 4. The execution context is the environment in which Javascript is executed. Think of execution contexts like a box which contains variables and our code when we talk about JavaScript code execution, we need to keep in mind the execution stack and scope All the code that is not inside any function is in GEC. So any variables or functions, not inside the function is in GEC. GEC is an object which in case of a browser it will be a window object, everything you declare in a global context will be attached to the window object Execution Contexts Global Execution Context (GEC)
  • 5. A stack data structure in which the new execution context is pushed on top of Global Execution Context. If inside the new execution context(which is a function basically) a new function is called it will create a new execution context and that new execution context is pushed on top of the previous execution context The global context is located in the first position from bottom to top in the execution stack. Every time a new context is created when a function is called, this placed at the top of the queue. Once it's executed, they are eliminated from top to bottom Execution Stack
  • 6. Argument object is created, which stores all arguments (if any) in a function. The code is scanned for function and variable declarations and creates a property in the variable object (VO) that points to those functions and variables before execution. This process is known as hoisting Creation of the variable object Elevate functions and variables by making them available before execution, albeit in different ways: • Functions: only those that are declared. It makes them fully available. • Variables: makes them available but as undefined Hoisting
  • 7. Scoping is where can the variable be accessed. Each function has its own scoping space where the variables are defined. Typically a scope is created by if for blocks but not in Javascript. New scope is created by only writing new functions. In Javascript we also have lexical scoping for example a function inside another function will access to its outer function Scoping and Scope Chain
  • 8. Each and every new execution context gets a this variable. In a regular function call “this” keyword points to window or browser object which is a global object. Important thing to remember is that the this keyword is not assigned a value until a function where a function where it is defined is called Scope Chain “this” variable As the flow of execution is followed, a chain of scopes belonging to the object variable is created to finally create the context object
  • 9. The execution stack is how the function calls are placed inside the execution stack, storing their context, while the scope chain refers to the scope of accessibility existing between the different contexts Remember !
  • 10. In this way, the context object is created and goes to the second phase, which is the line-by-line execution of the code within each context until each function call ends and they are removed from the execution stack Conclusion Thank you VIBHOR GROVER