Chap. 3 eloquent javascript Flashcards
Functions that don’t have a return statement at all, such as makeNoise, similarly return_____________.
undefined
let x = 10; if (true) { let y = 20; var z = 30; console.log(x + y + z); // → 60 }
// IS Y VISIBLE?
// y is not visible here
let x = 10; if (true) { \_\_\_ y = 20; \_\_\_ z = 30; console.log(x + y + z); // → 60 }
// what keyword to use to make Y NOT visible and Z VISBLE
let Y
var Z
const halve = function(n) { return n / 2; };
let n = 10; console.log(halve(100)); // → console.log(n); // →
// → 50 // → 10
FUNCTION DECLARTION OR EXPRESSION
function square(x) { return x * x; }
FUNCTION DECLARTION
_____________are not part of the regular top-to-bottom flow of control.
Function declarations
FUNCTION DECLARTION OR EXPRESSION
var square = function(x){ return x * x; }
FUNCTION EXPRESSION
The main difference between a function expression and a function statement is the function name, which can be omitted in function expressions to ________
create anonymous functions.
CONDENSE the code:
const square1 = (x) => { return x * x; };
const square1 = x => x * x;
//Write out as a arrow function
function funcName(params) { return params + 2; }
var funcName = (params) => params + 2
When an arrow function has no parameters at all, its parameter list is just ______________.
an empty set of parentheses.
function greet(who) { console.log("Hello " + who); } greet("Harry"); console.log("Bye");
“Hello Harry”
“Bye”
function square(x) { return x * x; } console.log(square(4, true, "hedgehog")); // →
// → 16
We defined function with only one parameter. Yet when we call it with three, the language doesn’t complain. It ignores the extra arguments and computes the square of the ______
first argument
If you pass too few, the missing parameters in a function get assigned the value ____________
undefined.