Binding, Functions and Control Flow - Reading Assignment

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.

  1. What is a binding?

Binding variable->Keeps the internal state, or remembers . Catches and holds values

  1. What is an environment?
    Environment-> set of bindings and their values that exist at a given time.

  2. 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

  1. 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:

  1. name function
  2. anonymous function
  3. 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.

  1. 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.

  2. 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);
}

  1. What kind of keyword do you need to use to invoke conditional execution?
    If, else, or//, and
1 Like
  1. An expression is a fragment of code that produces a value. Every value that is written literally. An expression between parentheses is also an expression, as is a binary operator applied to two expressions or a unary operator applied to one. Expressions can contain other expressions nested in.
  2. Bindings help program remember things, to catch and hold things.
  3. The environment is a collection of bindings and their values that exist at a given time.
  4. A Function is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.
  5. In browser environment for example: prompt(“Enter password”);
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. Function with side effect: alert(“My cool website at howmoney.work”) with value: console.log(Math.min(5, 345, 16) + 50);
  8. Control flow is when your program contains more than one statement. They are executed from top to bottom.
  9. When we want to create a branching road where the program takes the proper branch based on the situation at hand is called conditional execution.
  10. If, else, else if
1 Like

1] A fragment of code that produces a value
2] Catches and retains a value
3] A collection bindings and their values given time
4] A function is a piece of a program wrapped in a value
5] prompt (“Enter username”);
6] Changes that make a screen change or change the internal state of the machine
7] A function that produces a side effect: alert()
A function that produces a value: console.log()
8] A sequential execution of statements
9] The execution of statements based on a condition
10] if

1 Like
  1. What is an expression?
    An expression is a fragment of code that produces a value.

  2. What is a binding?
    JavaScript uses a binding to catch and hold values.

  3. What is an environment?
    The environment is the current collection of bindings and their values.

  4. What is a function?
    A function is a piece of program wrapped in a value.

  5. Give an example of a function.
    console.log(Math.max(2, 4));

  6. What is a side effect?
    Showing a dialog box or writing text to the screen is a side effect.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side Effect function: prompt(“enter passcode”);
    Value function: console.log(4 * 4);

  8. What is control flow?
    Control flow refers to the way JavaScript readys statements in your program as if they are written in a story, from top to bottom.

  9. What is conditional execution?
    Conditional execution is when the program follows different branches based on different situations.

  10. What kind of keyword do you need to use to invoke conditional execution?
    ‘if’, ‘else’

1 Like
  1. What is an expression?

A fragment of code that produces a value

  1. What is a binding/variable? keywords: let, var(pre-2015), const

An operation that catch and hold values

  1. What is an environment?

The collection of bindings and their values that exist at a given time

  1. What is a function?

A piece of program wrapped in a value

  1. Give an example of a function.

prompt(“Enter Bitcoin Address”);

  1. What is a side effect?

A statement that affects the world in terms of change — displaying
something on the screen — or changing the internal state of the machine in a way that will affect following statements

  1. Give an example of a function that produces a side effect and another function that produces a value.

function noeffect() {
1;
!false;
}

function sideeffect() {
prompt(“Enter Bitcoin Address”);
}

  1. What is control flow?

The execution of statements from top to bottom

  1. What is conditional execution?

The running of a program based on various optional criteria/terms/conditions that creates branches of statement code

  1. What kind of keyword do you need to use to invoke conditional execution?

keyword: if

1 Like
  1. An expression can be described as a sentence. It is a kind of statement that doesn’t have to produce any significant change in the program. Expressions can also contain other expressions.

  2. A binding is another kind of statement that is invoked by the keyword “let”, followed by the name of the binding, an = operator and then a value. A binding attaches to a value in a way that can be described as a string, or –as in the book – a tentacle (that grabs a value). The keywords var and const can also be used to create bindings.

  3. An environment is the collection of all bindings and values that exist at the same time. A program always has an environment, which is not only the code currently being executed by the user.

  4. A function is a piece of code contained inside a value. A value assigned to a function is called an argument.

  5. The console.log function was introduced early in the course and we should be familiar with it by now.

  6. A side effect is the change that occurs in the internal state of the machine that will affect following statements. The change is induced by a preceding function. Side effects have a purpose and some functions are used for the side effects they are producing; such as a dialog box (prompt). The Math.max function takes an amount of numbers and returns the greatest number.

  7. One example is the prompt function’s dialog box. The Math.max function, however, takes an amount of numbers and returns the greatest number and thus, is a function that returns a value.

  8. Control flow refers to the program executing the statements in a chronological order from top to bottom. This is essential because a statement can use the value returned by a previous statement.

  9. Conditional execution enables the program to choose which flow or path to follow, depending on whether a certain condition holds true.

  10. In order to invoke conditional execution, the keyword if must be used. This can be done in conjunction with the keyword else, which gives the program the option to follow the “other” flow or path.

1 Like
  1. What is an expression?
    A fragment of program that is useless by itself. It would correspond to a sentence fragment.
  2. What is a binding?
    Is a way to catch and hold values that otherwise would dissipate.
  3. What is an environment?
    It is a collection of bindings and their values.
  4. What is a function?
    A piece of program that is wrapped in a value.
  5. Give an example of a function.
    “In a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input.” (Eloquent Java Script, p. 26)
  6. What is a side effect?
    Is the writing text to the screen.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Prompt(“Enter username”)
    Console.log(Math.max(2,4))
  8. What is control flow?
    Is when a program contains more than one statement and the statements are executed from top to bottom because the second statement requires information from the first statement.
  9. What is conditional execution?
    When a program uses the keyword “if” in order for the program to make the correct selection based on the situation.
  10. What kind of keyword do you need to use to invoke conditional execution?
    If
1 Like
  1. An expression is a fragment of code that produces a value.
  2. A binding is a thing, such as a variable, that catches and holds a value.
  3. An environment is the collection of the bindings and values that are present at a given time.
  4. A function is a piece of a program that is wrapped in a value.
  5. An example of a function is: prompt(“Give an example of a function.”);
  6. A side effect is something that observable that occurs after a function runs such as displaying something on the screen or altering variable values that can impact the way a program acts in the future.
  7. A function that produces a side effect is: prompt("Give an example of a side effect: "); A function that doesn’t produce a side effect is: console.log();
  8. Control flow is how the program executes multiple parts of a program in consecutive order from top to bottom.
  9. Conditional execution happens when the program uses its situational awareness to execute the correct branch of the program.
  10. We need to use the keyword, if, to invoke conditional execution.
1 Like

What is an expression?
a programtic command within a statement

What is a binding?
another way of describing assinging a value to a variable

What is an environment?
The events and values within a running program

What is a function?
A compound statment, a mini piece of code which can be used within a larger peiece

Give an example of a function.
console.log

What is a side effect?
The effect produced by a bit of code

Give an example of a function that produces a side effect and another function that produces a value.
console.log
prompt();

What is control flow?
The path a program takes during it’s execution

What is conditional execution?
When control flow branches

What kind of keyword do you need to use to invoke conditional execution?
IF

1 Like

1. What is an expression?
Anything that produces a value.

2. What is a binding?
The thing that holds the value.
(var, const, let)

3. What is an environment?
A collections of bindings and their values.

4. What is a function?
A piece of program that uses a value.

5. Give an example of a function.
function myFunction() {
alert(“Hello World!”);
}

6. What is a side effect?
If the functions has an effect on somthing else. Does not only produce a value. (displaying text on a website)

7. Give an example of a function that produces a side effect and another function that produces a value.

alert (“Hello world”)

function Bruh(x){
return x+2;
};

8. What is control flow?
The order in how something gets executed (in JS it’s from the top down)

9. What is conditional execution?
When a part of the code is executed if it meets the right condition (e.g using the if keyword )

10. What kind of keyword do you need to use to invoke conditional execution?
if

1 Like
  1. An expression is a sentence fragment that gives a value. Direct values can also be an expression.
  2. A binding is a variable to which a particular value has been assigned and which is stored in computer memory.
  3. An environment is a collection of bindings and the values in those bindings that exist at a particular time reference.
  4. A function is a sequence of command is a program with certain defined instructions to follow. Every time we execute that function those same instructions or operations/calculations will be executed.
  5. alert(“Hello World”) is a predefined function.
    Example 2: function add (a,b) {
    Return a+b
    }
  6. Statements that generally doesn’t change the outside world (like displays in the screen) but change the internal state of the machine therefore affecting the statements that comes after it is called a side effect.
  7. function add (a,b){c=a+b;}
    function display (c ) {Return c}
  8. In javascript the statements are executed one after the other, i.e one that appears first is executed and then the following statements are executed. This is called control flow.
  9. In conditional execution certain statements are executed only when certain conditions are met.
  10. If; if-else; if-elseif-else; etc is used to invoke conditional execution.
1 Like
  1. Could be single value or set of values + operators creating an expression.
  2. LET and VAR are bindings. Something that can hold a value for future use etc.
  3. The collection of bindings and their values at a particular time.
  4. Function is something in which a code block is wrapped and can be used whenever it is called at a later stage.
  5. prompt(“Enter passcode”);
  6. A statement that could print something on screen make changes to the internal state of variables etc is called a side effect.
  7. prompt(“Enter passcode”) is a side function; Math.max(2, 4) is a return value function
  8. Statements in a program are executed like a story one by one from top to bottom.
  9. Used to execute one or another set of instructions based on the input given, or if certain conditions are met.
  10. If/Else/Case helps execute the code block conditionally
1 Like

1 - It’s a piece of code that results in a value
2 - Binding means assigning a value to a variable.
3 - The environment is the collection of bindings and values at a specific time
4 - A function is an expression that can be executed by calling it
5- prompt(“Insert Password”);
6 - Side Effects are functions that produce expressions and values
7 - alert(“Produces a side effect”); (5+7); gives a value
8 - The flow id the order of execution that JavaScript follows
9 - Conditional execution means that depending on the outcome JavaScript will proceed in a different direction.
10 - IF , ELSE

1 Like
  1. Expression is a fragment of code that produce a value
  2. Binding is a simple order to hold values of an expression
  3. Function is a piece of program wrapped in a value
  4. Environment is collection of bindings and their values that exist at a given time
  5. console.log(1 + 2);
  6. Side effect is the changes that happened on our screen related as the result of a function entry
  7. console.log(2*4) create values, alert(“sigh”) create side effect
  8. Control flow is the structure of order in the process of giving function a result
  9. Conditional Execution is a situation when there is a optional variable of statement that will have to be recognize by the function in order to have the exact result
  10. if({}) else {}
1 Like
  1. an expression is a piece of code that results in a value. An expression is usually the right-hand of an assignment/statement (but need not be so in JS)
  2. a binding is an assignment of a value to a placeholder of this value
  3. an environment is the set of bindings and values that exist in a moment of execution
  4. a function is piece of code that can result in a value, and/or results in another usefull “side effect” of its execution
  5. Math.max
  6. When a function interacts with the physical world to be usefull it is said a side effect of calling that function
  7. prompt(“enter input”); returns a string after the side-effect to show an input dialog when the function is called; Math.min(i,j) is a function that returns a value
  8. control flow is like a path to organize a program to cover several possible options and outcomes the program is prepared to handle and give results
  9. conditional execution lets you program several logic paths based on current value tests and assertions
  10. keywords like “if” and “else” but also “switch”, “break” and “continue” can create conditional code branches in your program
1 Like
  1. A fragment of code that produces a value is called an expression.
  2. With binding you can tie values to each other.
  3. The collection of bindings and their values that exist at a given time is called
    the environment.
  4. A function is a piece of program wrapped in a value.
  5. Console.log: is a function that writes out its arguments to some text output device.
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. Example: The function Math.max takes any amount of number
    arguments and gives back the greatest.
    console.log(Math.max(2, 4));
    // → 4
  8. Control flow: When your program contains more than one statement, the statements are
    executed as if they are a story, from top to bottom.
  9. Conditional execution is if it’s not a straight program. It takes the proper branch based on the situation at hand.
  10. The If statement
1 Like
  1. A fragment of code that produces a value.
  2. It catches, grasps and holds values (tentacle).
  3. It is the collection of bindings and their values that exist at a given time.
  4. It is a piece of program wrapped in a value. it can be executed by calling it or invoking it.
  5. prompt, alert, etc.
  6. Functions produce side effects if they modify states outsides its scope
    7.prompt(“Enter passcode”); has the side effect of a prompting dialogue box.
    console.log(Math.max(2, 4)); produces no side effect but a value
  7. The control flow defines the order in which the program statements are executed.
  8. Conditional execution means that some part of the code is going to be executed only if certain condition is fulfilled.
  9. conditional expressions like IF, ELSE, etc
1 Like
  1. An expression is a literal value like a number or a string

  2. binding is attaching an expression to a name - i.e. creating a variable (var x = 100) (var y = “Moose”)

  3. An environment is a state where certain values exist. For example a web page or a program where some variables have been defined.

  4. A function is set of instructions which can be applied to values or arguments. We can define what the function will do and what arguments it needs to act on and then ‘call’ the function and provide it with arguments.

  5. A side effect is something produced by a function which does not change or produce any values.

  6. console.log(“Hello”); produces a side effect (text on screen) while highestNumber = Math.max(1, 2, 3, 4); uses a function to change a variable.

8 - Control flow is the order in which the operations are processed,

9 - Conditional execution is when the if/else expressions are used to change the control flow and have certain commands executed only if certain conditions are met.

  1. if, else and else if (if there are multiple condition)
1 Like
1. What is an expression?

A piece of code that produces a value

2. What is a binding?

A binding defines a named variable that can hold a reference to a value.

3. What is an environment?

The collection of all bindings.

4. What is a function?

A piece of code wrapped up as a value with a name. The code in the function can be invoked by using name and adding parentheses i.e alert("hello").

5. Give an example of a function.
function add(a, b) {
return a + b;
}
6. What is a side effect?

Something that changes the state of the program

7. Give an example of a function that produces a side effect and another function that produces a value.
  • Has a side effect: console.log()
  • Returns a value: Math.max()
8. What is control flow?

Normally code is executed line by line from top to bottom. Control flow allows you to change this behavior creating multiple possible paths through the code such as branches and loops.

9. What is conditional execution?

Conditional statements allow a block of code to execute only if the condition statement evaluates to true. This creates multiple possible paths through the code, often called branches.

10. What kind of keyword do you need to use to invoke conditional execution?

They key word if is used i.e.

if (result > 0) {
   // do something
}
1 Like
  1. What is an expression? It is a combination of one or more constants, variables, functions, and operators that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce (“to return”, in a stateful environment) another value.

  2. What is a binding? Binding refers to the process of converting identifiers (such as variable and performance names) into addresses. Binding is done for each variable and functions. For functions, it means that matching the call with the right function definition by the compiler. It takes place either at compile time or at runtime.

  3. What is an environment? The collection of bindings and their values that exist at a given time is called the environment.

  4. What is a function? A function is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program. For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input. It is used like this:
    prompt(“Enter passcode”);

  5. Give an example of a function. For example, the function Math.max takes any amount of number arguments and gives back the greatest.
    console.log(Math.max(2, 4)); // → 4

  6. What is a side effect? A statement that cause any change in the internal state of the machine in a way that will affect the statements that come after it. These changes are called side effects.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    let theNumber = Number(prompt(“Pick a number”)); // produces side effect
    console.log("Your number is the square root of " + theNumber * theNumber); //produces value

  8. What is control flow? It is the direction of execution of code in JavaScript which happens in a top down approach.

  9. What is conditional execution? Conditional Execution is a branch in the control flow’s execution, where JavaScript picks a branch depending if the conditions that are present.

  10. What kind of keyword do you need to use to invoke conditional execution? if, else, else if, switch.

1 Like