Binding, Functions and Control Flow - Reading Assignment

An expression is a fragment of code that produces a value.

  1. What is a binding?

A binding is a relationship between a variable and the value of that variable. Used to catch and hold values.

  1. What is an environment?

An environment is the collection of bindings and their values that exist at a given time.

  1. What is a function?

A function is a piece of program wrapped in a value, which can be applied in order to run the wrapped program.

  1. Give an example of a function.

function f(x) { x+1};

  1. What is a side effect?

Anything that a user would experience as a result of the function, such as presenting a dialogue box or writing text to the screen, or making a noise.

  1. Give an example of a function that produces a side effect and another function that produces a value.
  • alert("This text is a side effect");
  • Math.max(2, 4);
  1. What is control flow?

Control Flow is the order that a computer executes sections of a program code.

  1. What is conditional execution?

Different actions are performed based on logical operators that assess whether an input meets a given condition, then executes the results of that conditional statement or moves on if the condition is not met.

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

if

1 Like

An expression is the name given to a segment of code of which produces a value. Expressions can be combined to form Statements allowing for complex programs .

Binding is the same as assigning a variable. JavaScript recognizes binding by the keyword let however this is not a permanent assignment. Values can be changed or even completely reassigned; it is not set forever.

The environment is the collective value of bindings at the current time. When the program first starts, the environment is not empty. There are always preset values part of the language standard regardless of assigned bindings.

“A function is a piece of program wrapped in value.” An example of this would be preset bindings which perform predetermined actions.

Referencing bindings, many of the preset values in the language standard are functions.

prompt(“Enter Passcode”);

In this example prompt is the function. The information inside the parentheses is known as the argument.

A side effect is essentially the action performed by a function.

Side Effect:
prompt(“Enter Passcode”); - the side effect is a text box pop up
Value:
console.log(Math.max(2, 4)); - the value is the max number (4)

Control Flow is the name given to the order of operations in code. The code is read like a book, top to bottom.

A conditional execution is an action performed if the appropriate parameters have been met. Think of it as a fork in the road.

if

1 Like
  1. fragment of code that produces a value
  2. keyword is “let” - works similiar as “var” - is used to hold values --> after a binding is defined it can be used as expression
  3. the collection of bindings and their values that exist at a given time is called the environment
  4. values provided in the default environment have the type “function” - a function is a piece of program wrapped in a value, such values can be applied in order to run the wrapped program
  5. prompt(); - holds a function that shows a dialog box
  6. Showing a dialog box or writing a text to the screen
  7. side effect: prompt(); value = math.max();
  8. operation order of code: top to bottom, left to right
  9. based on the situation at hand the program may should take a different route --> conditional execution
  10. if / else
1 Like
  1. A fragment of code that produces a value is called an expression
  2. a binding can be a variable it’s use to keep values. We tell JS that a variable is a variable using let (var also work but it’s the old way)
  3. the environment is the collection of all variables and their respective value
  4. A function is a piece of a program wrapped in a value that can be call
  5. console.log(“Helloworld”)
  6. It’s when a function or something else modifies the state of something outside of its own scope, then it’s a side effect.
  7. alert(“ALERTttt”), console.log(2+1)
  8. It’s the order that the computer read and execute the program
  9. It’s an execution of a part of the program that happen only if the condition indicated by the dev is respected.
  10. if
1 Like
  1. What is an expression?
  • The definition of expression is recursive: Values are expressions, “(expression)” is expression, “expression<binary_operator>expression” is expression, “<unary_operator>expression” is expression.
  1. What is a binding?
  • Binding is the mechanism to “hold on” to values and reuse them throughout the code
  1. What is an environment?
  • environment is the collection of bindings and their values that exist at a given time
  1. What is a function?
  • A function is special type of value represented by a bundle of some program code bound (or not in the anonymous case) to a variable name. This is the mechanism to provide reusable chunks of code.
  1. Give an example of a function.
  • alert(), console.log("…")
  1. What is a side effect?
  • Side effect of a function is the change that execution of a function introduces in its environment other than returned value.
  1. Give an example of a function that produces a side effect and another function that produces a value.
  • console.log("") produces a side effect, Math.pow(base, exponent) produces value
  1. What is control flow?
  • Control flow denotes the sequence in which the program statements will be executed.
  1. What is ?
  • Conditional execution introduces constructs that allows a program to choose which code to execute and which to skip based on a condition
  1. What kind of keyword do you need to use to invoke conditional execution?
  • if/else, switch
1 Like
  1. What is an expression?
    A fragment of code that produces a value.
    Every value that is written literally (such as 22 or “psychoanalysis”) is an expression. An expression between parentheses is also an expression, as is a binary operator applied to two expressions or a unary operator applied to one.

    If an expression corresponds to a sentence fragment, a JavaScript statement corresponds to a full sentence. A program is a list of statements.

  2. What is a binding?
    To catch and hold values, JavaScript provides a thing called a binding, or variable:
    ex. let caught = 5 * 5;

    The previous statement creates a binding called caught and uses it to grab hold of the number that is produced by multiplying 5 by 5.You should imagine bindings as tentacles, rather than boxes. They do not contain values; they grasp them—two bindings can refer to the same value.

    You should imagine bindings as tentacles, rather than boxes. They do not contain values; they grasp them—two bindings can refer to the same value.

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

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

  5. Give an example of a function.
    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”);

  6. What is a side effect?
    Changes to the internal state of the machine in a way that will affect the statements that come after it.

    Showing a dialog box or writing text to the screen.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side effect: prompt(“Enter passcode”);

    Value: console.log(Math.max(2, 4));
    // → 4

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

  9. What is conditional execution?
    Not all programs are straight roads. We may, for example, want to create a branching road, where the program takes the proper branch based on the situation at hand.

  10. What kind of keyword do you need to use to invoke conditional execution?
    If
    In the simple case, we want some code to be executed if, and only if, a certain condition holds.

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

  2. What is a binding?
    It is a variable that is used to catch and hold values.

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

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

  5. Give an example of a function.
    prompt(“Enter passcode”);

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

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Function that produces a side effect:
    alert(“hello”);

Function that produces a value:
console.log(Math.max(2, 4));

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

  2. What is conditional execution?
    Conditional execution happens when we create a branching road, where the program takes the proper branch based on the situation at hand.

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

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

  2. A binding catches and holds a value, so the computer can remember the information it is given

  3. The environment is the collection of bindings and their values

  4. A fuction is a peice of programme that is wrapped in a value.

  5. An example of a fuction is: prompt(“enter a number”);

  6. A side effect is when, for example, a function modifies another peice of the code out side of its own scope.

  7. Prompt(“what is your name”); produces a side effect
    console.log(9*6); produces a value

  8. Control flow is the direction of what the computer reads when there is multiple satements, it flows from top to bottom.

  9. A conditional execution is when a programme executes a set of opperation when the protocol is met within the code, taking it in one directionor the other.

  10. to invoke the conditioinal execution the keyword used is “if”. without quotations.

1 Like

1.) Its a fragment of code that produces a value is called an “expression”
2.) A binding is a function for the program to remember states. It is also called variable. Example: “let”.
3.) An Environment is a list of bindings and their values.
4.) A function is something that creates an output of an input.
5.) console.log is such a function.
6.) Showing a dialog-box or writing a text to the screen is a side effect.
7.) The prompt() function produces a side effect. The console.log function can create a value and has the side effect like in this example: let ten = 10; console.log(ten * ten); // → 100
8.) The flow of execution in javascript is from top to bottom. With control flow statements you can break that regular flow.
9.) It is created with the “if” keyword in javascript. You can make a function like this: Put out A but only “if” A is a value.
10.) if

1 Like

What is an expression?

An expression is any piece of code that returns a value; expressions may be stacked on top of one another to form larger expressions.

What is a binding?

A binding is a value or string that is assigned to a variable; it is useful to create bindings such that you do not have to repeat the same expression in the programme.

What is an environment?

An environment is made up of all the bindings that have been created within a programme.

What is a function?

A function is a programme section that executes a particular purpose. It can then be linked to in other expressions.

Give an example of a function.

alert(“I am a tool”);

What is a side effect?

A side effect occurs when a declaration or function modifies the status of something else (outside of its own scope).

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

let num = 0;
const func = () => {
num = 1;
return true;
}
func();

What is control flow?

The sequence in which we code and have our statements checked is referred to as control flow.

What is conditional execution?

Conditional execution denotes that a condition is only enforced until a predefined condition is met.

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

Use

if

to specify a block of code to be executed if a specified condition is true

Use

else

to specify a block of code to be executed if the same condition is false

Use

else if

to specify a new condition to test, if the first condition is false

Use

switch

o selects one of many blocks of code to be executed

1 Like

1. What is an expression?
A fragment of code that produces a value.
2. What is a binding?
It is a variable used to catch and hold values.
3. What is an environment?
The collection of bindings and their values that exist at a given time
4. What is a function?
A function is a piece of program 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.
6. What is a side effect?
It is any application state change that is observable outside the called function other than its return value.
7. Give an example of a function that produces a side effect and another function that produces a value.
The alert() function will produce a side effect, and the Math.min() function will produce a value.
8. 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.
9. What is conditional execution?
Branching road, where the program takes the proper branch based on the situation.
10. What kind of keyword do you need to use to invoke conditional execution?
If/ Else or a combination of both.

1 Like
  1. An expression is a combination of variables, values and operators.

  2. Binding is where an object ,can be bound to a function so the function can produce a different result.

  3. An environment is a group of bindings with their values existing together at a specific time.

  4. A function is a piece of code that can calculate a value ,or perform a task as an input and return an output.

  5. function my function( ) {
    return "hello ";
    }

  6. Writing text to a screen or showing a dialog box is a side effect

  7. math.max(2, 4);

→ 4

math.min 92, 4) +100;

→ 102

8.Control flow is the order in which the programme executes statements in a script from top to bottom.

9.Conditional execution controls regardless or not the core will execute an instruction.

  1. IF ,and Else
1 Like
  1. What is an expression?
    A fragment of code that produces a value.
  2. What is a binding?
    Binding or valuable is provided by JavaScript to catch and hold values.
  3. What is an environment?
    The collection of bindings and their values that exist at a given time.
  4. What is a function?
    Piece of program 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.
  6. What is a side effect?
    Showing a dialog box or writing text to the screen.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    console.log - side effect
    math.max - value
  8. What is control flow?
    The order in which the computer executes statements in the script. Straight road
  9. What is conditional execution?
    The order (branching road), where the program takes the proper branch based on the situation at hand.
  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 produce a value is called and expression. The simplest statement is an expression with a semicolon after it.

  2. What is a binding? It’s a statement with keyword, the keyword can be used as an expression. Bindings does not hold values forever. Two bindings can refer to the same value. A binding name can start with anything except a number.

  3. What is an environment? The collection of bindings and their values that exist at a given time is call the environment. When a computer starts-up the environment is not empty.

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

  5. Give an example of a function. Like a dialogue box needing a password

  6. What is a side effect? You have no control over the way the dialogue looks.

  7. Give an example of a function that produces a side effect and another function that produces a value. Showing a dialogue box, such as a prompt for a password is a side effect. To produce a value, is usually comparing number arguments and returning a value.

  8. What is control flow? When a program contains more than one statement, the statements are executed from top to bottom.

  9. What is conditional execution? Conditional execution is a control flow, which uses the word “if” which causes a branch, and not a straight flow.

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

1 Like
  1. An Expression is a value produced by a fragment of code.
    Every value like integers or strings is an expression.
  2. A binding is to hold values. First you bind a value to an expression by defining it , then you can use it as expression later on.
    You can define a binding and change it later on with an =
    sign
    so that the old binding gets overwritten.
  3. The Environment is the collection of bindings and values given so far. If you add new bindings and values they will be part of the environment. When a new program starts you will have some predefined bindings.
  4. Bindings can hold functions which are used to make do something. For example: If you are programming a website where your visitor has to interact with it there is a function which reacts on the given input.
  5. The login window is an example for a function. In the binding prompt the function communicates to the system to open a dialog box for input. The string which follows communicates what to enter to the visitor. In the best case scenario the binding includes a function to check if the input is correct.
  6. A side effect is an effect that come together with the actual purpose of the function.
  7. The actual function of the loginwindow is to take the input from the user (username & password) and return it to the website. The side effect is the loginwindow which is visualized to the user. A function that produces a value ,like the Math.max function takes your input, calculate the right answer and gives you the correct value back.
  8. Control flow describes in which order the program is read and executed.
  9. If there is no conditional execution, the program will be read in a straight line similar to when you read a book. You would read the book from left to right and from the top to the bottom. However in case the book would tell you to skip some pages under specific conditions it would be called conditional execution. If a happens you do this if b happens you do that.
  10. ‚if‘ is the keyword to invoke conditional execution.
1 Like
  • What is an expression?
    expression is simply a way of asking a question that
    gets answered with a value — and always a single value .

  • What is a binding?
    binding- relates to specifying which this or object context*

  • What is an environment?
    The collection of bindings and their values that exist at a given time

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

  • Give an example of a function.
    Prompt(“Enter passcode”);

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

  • Give an example of a function that produces a side effect and another function that produces a value.
    Side effect:
    console.log(Math.max(2, 4));
    // → 4
    Value
    console.log(Math.min(2, 4) + 100);
    // → 102

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

  • What is conditional execution?
    When we want to create
    a branching road, where the program takes the proper branch based on the
    situation at hand.

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

1 Like
  1. A expression is a piece of code that produce a value.
  2. binding catches and holds values.
  3. environment is a collection of bindings and values.
  4. function is a piece of code wrapped inside a value.
  5. prompt (" Enter Username")
  6. Side effects are the printed result of a function displaying dialog box or written text.
  7. console.log(Math.max( 17, 98) ); = 98
    console.log(Math.min( 3,9) + 458); = 461
  8. More than one statement which is executed in story book form. top to bottom
  9. Conditional execution occurs when “if” is added to chose a second route (if value is this, then do this)
  10. If.
1 Like
  1. A fragment of code that produces a value.
  2. An expression can be bound into a variable. If we define, that a = 5, then “a” is a binding and 5 is its expression.
  3. The collection of bindings and their values that exist at a given time.
  4. A function is a piece of program wrapped in a value. Wrapped program can be run by applying those values.
  5. Prompt(); is a function where values are added inside the parentheses.
  6. Side effects are when a function shows a dialog box or print text to the screen, when function does something else than produces values.
  7. Prompt(); produces a side effect and Math.max(); produces a value.
  8. Program’s statements are executed in order from top to bottom.
  9. Conditional execution means that a program can execute in different ways due to applied criteria.
  10. If, else.
1 Like
  1. An expression is a string of code that produces a value.
  2. A binding is a variable that you set to a value.
  3. An environment is composed of the currently established values and bindings.
  4. A function is a string of code that commands the program to perform a task.
  5. prompt, alert
  6. A side effect is when a function changes how the program is running.
  7. prompt(“How is your day?”);
    console.log(2 + 2);
  8. Control flow is the order in which code is executed.
  9. When a condition must be met for the function to execute properly.
  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?
A binding is a variable and it lets you keep values. A binding is indicated by the keyword let, followed by the name of the binding. A binding can be given a value by an = operator and an expression.

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

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

5. Give an example of a function.

prompt(“enter a passcode”)

6. What is a side effect?
In case of a prompt the side effect is a dialog box.

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

prompt(’'enter a passcode")

console.log(Math.max(2 ,4 ,28 , 829));

8. What is control flow?
It’s a flow of statements that execute from top to bottom.

9. What is conditional execution?
Not all programs are straight roads. We may, for example, want to create a branching road, where the program takes the proper branch based on the situation at hand. This is called conditional execution.

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

1 Like