YDKJS Up and Going Flashcards

1
Q

How do you quickly retrieve input in a browser popup?

A

const answer = prompt('Type answer');

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

What are objects?

A

Values that hold other values at specific named locations called properties.

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

A block is…

A

one or more statements wrapped inside a curly-brace pair {...}

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

An iteration is..

A

each time a loop block executes.

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

You can stop a loop with..

A

the break statement

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

Each function gets its own..

A

scope

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

Lexical scope rules say that one scope can access variables of…

A

…either that scope or any scope outside (not inside) it

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

The built-in types are…

A

6 primitives:

  • string
  • number
  • boolean
  • null
  • undefined
  • symbol (new in ES6)

and object

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

Use ____ to tell you the type of a value currently in variable

A

typeof variable

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

Variables can get to the undefined state from…

A
  • functions that have no return value
  • the void operator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

typeof returns

A
  • function type, a subtype of object
  • implying it can have properties, although this won’t be used often
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Object wrappers that pair with their primitive type and define method swhich go on its prototype are called…

A

natives.

string value -> String object

number value -> Number object

so on for all primitives that have properties and methods

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

When using a primitive value as an object by referencing a property or method…

A

JS automatically “boxes” the value in its object wrapper to enable the use of properties and methods.

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

All “falsy” values are:

A
  • ""
  • 0, -0, Nan
  • null, undefined
  • false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Examples of “truthy” values are:

A
  • "hello"
  • 42
  • true
  • [], [1, 2, 3]
  • {}, {a: 42}
  • function foo() {...}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between == and ===?

A
  • == checks for value equality with coersion allowed
  • === checks for value equality without coercsion allowed
17
Q

During inequality operations, if one or both values is not a string

A

…then both values are coerced to be a number, and then compared.

18
Q

Variables must be a valid ______ (which must begin with ___ )

A

identifier….any letter, $, or _

19
Q

The var keyword declares a variable that will belong to…

A

the current function scope, or global scope if at the top level outside of any function

20
Q

var and hoisting

A
  • a var declaration is hoisted to the top of its enclosing scope so that it can be accessible anywhere in the scope
  • the value assignment is not hoised, just the declaration
21
Q

Trying to access a variable’s value in a scope where it’s not available will cause…

A

…a ReferenceError to be thrown

22
Q

the let keywords enables you to declare variables…

A

that belong to individual blocks, contained within curly-braces {...}

23
Q

In a switch statement, you must use _____ if you only want one case to run, otherwise it will ‘fallthrough’ to other matching cases

24
Q

Strict mode disallows….

A

implicit auto-global variable declaration from omitting var

25
`var x = function bar() { // ..};` is ...
...a named function expression
26
`var x = function() { // ..};` is...
an anonymous function expression
27
`(function() { // ..})();` is...
* ...an immediately invoked function expression (IIFE) * outer `(...)` treats it as a function expression instead of function declaration * the final `()` executes the function
28
Closures are a way to...
"remember" and *continue to access* a function's scope (its variables), *even once* the function has finished running
29
The module pattern returns...
...an object that references functions which will remember and continue to access their scope
30
`this` gets set in one of these four ways...
* from the global object * an object on which it is called from * an object from which it is called by way of `call` or `apply` * a blank object if using `new ()`
31
Prototype Lookup
If referencing a property on an object, and it doesn't exist, JavaScript will automatically use the object's internal prototype reference to find another object to look for the property on
32
Transpiling is
converting newer code into older code equivalent
33
`document` is a special object that exists as a global variable and is called a...
"host object"