functions Flashcards
A function definition is a regular _______ where the value of the binding is a function.
binding
Functions have a set of parameters and a ______, which contains the statements that are to be executed when the function is called.
body
Some functions produce a value, such as power and square, and some don’t whose only result is a _____ _____.
side effect
A ______ statement determines the value the function returns.
return
A return keyword without an expression after it will cause the function to return ________.
undefined
Functions that don’t have a return statement at all return _________.
undefined
Parameters to a function behave like regular bindings, but their initial values are given by the _____ of the function, not the code in the function itself.
caller
Each binding has a ______, which is the part of the program in which the binding is visible.
scope
or bindings defined outside of any function or block, the scope is the whole program—you can refer to such bindings wherever you want. These are called _____.
global
Bindings created for function parameters or declared inside a function can be referenced only in that function, so they are known as _____ bindings.
local
Bindings declared with let and const are _____ to the block that they are declared in.
local
let x = 10; if (true) { let y = 20; var z = 30; console.log(x + y + z); }
console.log(x + z);
what are both outputs?
60
40
var z is visible outside its block once declared
Old-style bindings, created with the ______ keyword, are visible throughout the whole function that they appear in—or throughout the global scope, if they are not in a function.
var
const halve = function(n) { return n / 2; };
let n = 10; console.log(halve(100));
console.log(n);
what are the outputs?
50
10
________ scoping (sometimes known as static scoping ) is a convention used with many programming languages that sets the scope (range of functionality) of a variable so that it may only be called (referenced) from within the block of code in which it is defined. The scope is determined when the code is compiled.
Lexical