Understanding the Weird Parts of JS Flashcards

1
Q

syntax parser

A

a program that reads your code, determines what it does, and if its grammar (or syntax) is valid

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

compiler

A

interpretors for computers so the computer understands your code and converts it into instructions

it goes through code character by character

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

lexical environment

A

where something sits physically in the code you write

ie. a variable is on line 13 in the code

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

execution context

A

a wrapper to help manage the code that is running

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

object

A

a collection of name/value pairs

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

global execution context

A
  • the base execution context
  • creates 2 things in our code by the JS engine:
    1. a global object
    2. a special variable ‘this’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

the window object

A
  • the global object in browsers
  • each window open in the browser has its own global object
  • at the global level, the ‘this’ object is the same as the window object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

global

A
  • not inside a function
  • code or variables not within a function
  • when you create variables + functions not inside a function, they get attached to the global object
  • there is no outer environment at the global level

ex:
in code:
const a = ‘Hello world!”;

in the console:
a // => ‘Hello world!’
window.a // => ‘Hello world!’
this.a // => ‘Hello world!’

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

execution context

A

table:

global object | ‘this’ | outer environment
_________________________________
your code!

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

hoisting

A

setup memory space for variables and functions

  • a function in its entirety is saved in memory
  • a var name is saved (not the case for let or const)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

undefined

A
  • a special value in JS
  • the variable name exists, but the value has not been set, so JS sets the variable to the value ‘undefined’ and saves it to memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Uncaught referenceError: [var name] is not defined

A

means that a variable has not been declared and saved to memory

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

single threaded synchronous execution

A
  • single threaded: one at a time
  • synchronous: one at a time in order

JS is executed line be line in the order of the code

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

execution stack

A
  • whichever execution context that is on top of the stack is the one that is currently running
  • every time a function is called, it’s put on top of the stack
  • once the function finished executing, it is removed from the stack
How well did you know this?
1
Not at all
2
3
4
5
Perfectly