JavaScript P1 Flashcards
JavaScript is related to Java T/F
False
JavaScript is not______, it is ________.
compiled, interpreted
Loosely-typed
variable types are assigned at runtime
Undefined (keyword)
declared but not defined
Not Defined (keyword)
not defined or declared
Primitive Datatypes
undefined boolean number string bigint symbol null
falsy types
-0 0 undefined false " " NaN
truthy types
true
1
object
everything else that isn’t falsy
null
special primitive type having additional usage for its value: if object is not inherited, then null is shown
typeof()
returns the type of the ‘thing’ in ()
type coercion
changes the type of a variable when it is defined in another location
Arrays
variable in length and type
Functions: Three Invocations
Function form
Constructor form
Method form
Function form
“this” refers to the global object
no overloading
Constructor form
“this” refers to the object being made
Method form
“this” refers to the object its based off
Scopes: three types
Function Scope
Global Scope
Shadowing
Function Scope
Things that are declared inside a function
use keyword var
if you don’t use ver, creates implicit global
Global Scope
anything declared outside of a function
accessible anywhere
Shadowing
if multiple variables have this same name, JS will use the one that was declared most recently
____ does not escape blocks, ____ does
“let”, “var”
Hoisting
moving declarations to top of scope
var
a way to declare a variable
able to be reassigned
scope can be global or local
let
preferred way to declare variables
able to be reassigned
scope is restricted to the block they were declared in
const
variable can not be reassigned after declaration
scope is restricted to the block they were declared in
prototype
mechanism by which JS objects inherit features from one another
Arrow Notation
syntactically compact alternative to a regular function expression
closure
an inner function that has access to the outer function variables