Section 2: Execution Contexts and Lexical Environments Flashcards

1
Q

Name/Value Pair

A

A name which maps to a unique value.

The name may be defined more than once, but only can have one value in any given context.

That value may be more name/value pairs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Object

A

A collection of name value pairs. the simplest definition when talking about Javascript.

This is in Javascript, Object might be different or more complicated in other programming languages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When a javascript file is run, an execution context is created. What two things are created for you when that happens?

A
  1. A Global object

2. a special variable called ‘this’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Global Object

A

Base execution context. There will be a different global object if you’re running on a server but there will always be a global object when running Javascript.

Global Object is available to ALL code running inside the javascript file, the lexical environment.

Global object inside browsers is the ‘window’ object and ‘this’ then refers to the global object, ‘window’.

Global object means “not inside a function”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens to variables and functions when lexically they’re not sitting inside a function?

A

They become attached to the window (when running javascript in a browser) or global object.

So, ‘this’ is the window object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Hoisting

A

tbd…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The execution context: creation phase

A

Phase 1 of execution context

Global object setup, ‘this’, Outer Environment

Also sets up memory space for variables and functions aka “hoisting”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Javascript and ‘undefined’

A

‘undefined’ is a special value in javascript that means the value of the variable has not been set.

DIFFERENT than a reference error… if a variable is set up with the memory space during execution context creation phase, the variable will have a value called ‘undefined’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When should you declare a value of ‘undefined’?

A

NEVER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

the execution context: execution phase

A

Phase 2 of execution context

Runs your code line by line, interpreting it, converting it, compiling it, executing it on the computer into something the computer can understand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

single threaded (execution)

A

One command is being executed at a time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

synchronous execution

A

One [line of code] at a time AND in order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

[function] invocation

A

running or “calling” a function

In Javascript, by using parenthesis ()

Every invocation creates a new execution context which goes through both phases and gets put on the (top of the) execution stack.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Variable environment

A

Where the variables live.

And how they relate to each other in memory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Scope

A

Where a variable is available in your code

and if it’s truly the same variable, or a new copy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Block scoping

A

In ES6 the variable c that’s inside of the block will not be accessible outside of that block. This is a more familiar concept in other programming languages. You can also use let and var in ES6.

if (a > b) { let c = true; }

17
Q

Asynchronous

A

More than one at a time.