YDKJS Up and Going Flashcards
How do you quickly retrieve input in a browser popup?
const answer = prompt('Type answer');
What are objects?
Values that hold other values at specific named locations called properties.
A block is…
one or more statements wrapped inside a curly-brace pair {...}
An iteration is..
each time a loop block executes.
You can stop a loop with..
the break
statement
Each function gets its own..
scope
Lexical scope rules say that one scope can access variables of…
…either that scope or any scope outside (not inside) it
The built-in types are…
6 primitives:
string
number
boolean
null
undefined
-
symbol
(new in ES6)
and object
Use ____ to tell you the type of a value currently in variable
typeof variable
Variables can get to the undefined
state from…
- functions that have no return value
- the
void
operator
typeof
returns
-
function
type, a subtype ofobject
- implying it can have properties, although this won’t be used often
Object wrappers that pair with their primitive type and define method swhich go on its prototype are called…
natives.
string
value -> String
object
number
value -> Number
object
so on for all primitives that have properties and methods
When using a primitive value as an object by referencing a property or method…
JS automatically “boxes” the value in its object wrapper to enable the use of properties and methods.
All “falsy” values are:
""
-
0
,-0
,Nan
-
null
,undefined
false
Examples of “truthy” values are:
"hello"
42
true
-
[]
,[1, 2, 3]
-
{}
,{a: 42}
function foo() {...}
What is the difference between ==
and ===
?
-
==
checks for value equality with coersion allowed -
===
checks for value equality without coercsion allowed
During inequality operations, if one or both values is not a string
…
’
…then both values are coerced to be a number
, and then compared.
Variables must be a valid ______ (which must begin with ___ )
identifier….any letter, $
, or _
The var
keyword declares a variable that will belong to…
the current function scope, or global scope if at the top level outside of any function
var
and hoisting
- 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
Trying to access a variable’s value in a scope where it’s not available will cause…
…a ReferenceError
to be thrown
the let
keywords enables you to declare variables…
that belong to individual blocks, contained within curly-braces {...}
In a switch
statement, you must use _____ if you only want one case
to run, otherwise it will ‘fallthrough’ to other matching case
s
break
Strict mode disallows….
implicit auto-global variable declaration from omitting var