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.
function minus(a, b) {
if (b === undefined) return -a;
else return a - b;
}console. log(minus(10));
console. log(minus(10, 5));
// → -10 // → 5
console.log(undefined === undefined);
TRUE
TRUE OR FALSE
If you write an = operator after a parameter, followed by an expression, the value of that expression will replace the argument when it is not given.
TRUE
A function that calls itself is called___________.
recursive
When you only have one parameter in an arrow function, the opening parenthesis are optional:
TRUE OR FALSE
TRUE
https://codeburst.io/javascript-arrow-functions-for-beginners-926947fc0cdc
In a arrow function if you are returning an expression, you remove ____________
the brackets
var myCar = new Car('Ford', 'Escape');
console.log(myCar);
// ?=> Car {make: “Ford”, model: “Escape”}
function add(c, d) {
console.log(this.a + this.b + c + d);
}
add(3,4);
// logs and whyNaN
a and b are undefined