JS ninja Flashcards
what are the steps of the page building phases?
- Parsing the html and building the DOM
2. Executing JS code
What is the DOM?
It’s a structured representation of the HTML page in which every HTML element is represented as a node
what happens when the browser encounters the script tag while constructing the DOM?
the browser pauses the DOM construction from HTML code and starts executing JavaScript code
which is the primary global object that the browser exposes to the JS engine?
The primary global object that the browser exposes to the JavaScript engine is the window object
how does the browser keeps track of all the events that have occurred?
the browser uses an event queue
Describe the event handling loop
- check the head’s queue for pending event handlers to be executed
- if the is one, goto step 3, else goto step 1
- executed the event handler, goto step 1
which are the 2 phases of the execution of a client app?
- page building
2. event handling
how many event can be processed at a time?
only one, JS in single threaded by default
In what order are events from the event queue processed?
In the same order in which they were triggered: the queue follows a FIFO logic
first in first out
what are the 3 most important ways that JS provides for the definition of a function
- function declarations and function expressions
- arrow functions
3 functions generators
What are rest parameters?
Rest parameters enable us to reference the remaining arguments that don’t have matching parameter names.
which are the implicit function parameters?
The implicit function parameters are ‘this’ and ‘arguments’
What is the ‘this’ parameter?
The this parameter refers to an object that’s associated with the function invocation. For this reason, it’s often termed the function context.
How many ways are there for invoking a function in JS? List them and briefly describe them
There are 4 way:
- The simple form foo()
- as a method ninja.foo()
- as a constructor new Foo()
- via the apply or call methods foo.apply(ninja) or foo.call(ninja)
What is the value of the ‘this’ object when invoking a function in the first simplest form => foo()
- In the nonstrict mode it will the global context, the window object
- in strict mode it will be undefined