General Flashcards
1
Q
Compiler
A
- Converts code from one language to another
- Generally converts from a higher level language to a lower level language
2
Q
Linker
A
- combines the various files produced by compiler
- generates executable code that computer actually interacts with
3
Q
statement vs expression
A
- expression is a unit of code that returns a value
- a = 1 (returns a)
- a == True
- statement is a unit of code that just does work
- doesn’t return a value
- if statement, for loop
4
Q
Lexical Environment
A
- The location of code within a program
- For example, a variable might sit lexically inside a function
5
Q
Object
(in Javascript)
A
- A collection of key/value pairs
6
Q
Execution Context
A
- The environment/state of a function that is created by involking a function
- A new execution context is created every time a function is invoked
- Includes
- the variables in scope
- function arguments
- the this variable (the context)
7
Q
Lexical Scoping
A
- Also called compile-time scoping
- The scope of all variables is determined at compile time, by the location of the variables
- Basically normal scoping
- Most languages (including JS) have lexical scoping
8
Q
Hoisting
A
- Process of allocating memory for variables and functions during the compilation phase
- Or, the process of “moving declarations” to the top of the current scope
Three scenarios during compilation phase:
-
Variable Names
- Are put into memory
- Declarations are hoisted, but variables are set to undefined
- Naked variables (variables without a keyword) are not hoisted
-
Functions Declarations
- Are put into memory
- They are hoisted, and can be used before being explictly defined
-
Function Expressions
- Names are put into memory, set to undefined
- Using function expressions before defining them throws a TypeError
9
Q
undefined
A
- a primative type
- a special value that is automatically assigned to variables upon declaration
- Indicates that a variable has not been given a value yet
10
Q
single threaded
A
- One command is being executed at a time
11
Q
synchronous
A
- Tasks are completed in order
- JavaScript itself is synchronous, but it can make callback requests and create asynchronous behavior
12
Q
asynchronous
A
- asynchronous code allows you to start something now and finish it later
- does not have to complete tasks in order
13
Q
let
A
- Variable keyword
- New to EC6
- Allows you to create variables whose scope is just a block
- things with curly braces
- if statements, for loops, etc.
-
let variables are hoised, but…
- are hoisted: replace any reference to variables in outer scope
- but, using let variable before initialization throws a reference error, as opposed to undefined with var
- Syntax
Example (in an if statement):
console.log(c)
let c = 100
*Throws a reference error, even if c was already defined outside of block
14
Q
const
A
- variable keyword
- new to ES6
- like let, they create block-scoped variables
- however, variables cannot be reassigned
- primative variables cannot be changed
- variables set to objects can be changes, but not reassigned
15
Q
Event Handling
in JavaScript
A
- JS only processes events when execution stack is empty
16
Q
dynamic typing
A
- type of variable is determined at runtime (versus compile time)
17
Q
Primative Types
(JavaScript)
A
- a built in data type
- data that is not an object and has no methods
- all primitives are immutable
- all primatives (except null and undefined) have object wrappers
6 Primative Types
- undefined
- null
- boolean
- number
- only one ‘number’ type in JS
- it’s a floating point number
- string
- symbol
- New to ES6