What is an expression?
expression- a fragment of code that produces a value. Sometimes expressions are surrounded by parentheses such as a binary operation or a unary operation.
- What is a binding?
Binding variable->Keeps the internal state, or remembers . Catches and holds values
-
What is an environment?
Environment-> set of bindings and their values that exist at a given time. -
What is a function?
function->piece of program that is wrapped in a value
invoking, calling, or applying → are executive functions.
arguments->values given to functions
function ->regular binding where the value of the binding is a function for example, this code defines square to refer to a function that produces the square of a given number. A function is created with an expression that starts with the key word function. Functions have a set of parameters and a body, which contains the statements that are to be executed when the function is called. The function body of a function created this way must always be wrapped in braces, even when it consists of only a single statement. -may have multiple or no parameters. Some functions produce a value such as power and square, and some don’t.
-Functions are a fundamental building block of JS. Set of statements that preforms a task or calculates a value.
Function is a call to action.
Accepts arguments and runs commands.
function + verb+ return
function+add+return
- Give an example of a function.
Function go(){
alert(name);
alert(age);
}
function add (first, second)
return first+second;
-after the first return,
3 types:
- name function
- anonymous function
- immediately invoked function expression.
Functions are a piece of code that does one or more actions.
Takes input and produces output.
4. What is a side effect?
Side effects-> when an expression changes something that will affect the statements that come after it.
-
Give an example of a function that produces a side effect and another function that produces a value.
An example is when an argument throws away the value of 1 and true.
Or a person is defined as a minor 18> and ineligible for an opportunity. -
What is control flow?
When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom. This example program has two statements. The first one asks the user for a number, and the second, which is executed after the first, shows the square of that number.
let theNumber = Number(prompt(“Pick a number”)); console.log("Your number is the square root of " +
theNumber * theNumber);
7. What is conditional execution?
This is a conditional clause. The results of the “then” are determined by the “if”
One example is if you wanted to greet men and women differently, you might write good morning A//B a=guys b=ladies
let theNumber = Number(prompt(“Pick a number”)); if (!Number.isNaN(theNumber)) {
console.log("Your number is the square root of " + theNumber * theNumber);
}
- What kind of keyword do you need to use to invoke conditional execution?
If, else, or//, and