Binding, Functions and Control Flow - Reading Assignment

A fragment of code that produces a value is called an expression.

To catch and hold values, JavaScript provides a thing called a binding, or variable.

The collection of bindings and their values that exist at a given time is called the environment. For example, in a browser there are functions to interact with the currently loaded website adn to read mouse and keyboard input.

A function is a piece of program wrapped in a value. Such values can be applied in order to run a wrapped program. A clear example of a function is a dialogue box in a browser setting prompting the user to enter a passcode.

Showing a dialog box or writing text to the screen is a side effect. For example, Math.max takes any amount of number arguments and gives back the greatest.

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

// → 4

Modifying any external variable or object property (e.g., a global variable, or a variable in the parent function scope chain)

  • Logging to the console.
  • Writing to the screen.

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

// → 4

  • Writing to a file.
  • Writing to the network.
  • Triggering any external process.
  • Calling any other functions with side-effects.

The control flow is the order in which the computer executes statements in a script. A typical script in JavaScript or PHP (and the like) includes many control structures, including conditionals, loops and functions. Parts of a script may also be set to execute when events occur.

Code is run in order from the first line in the file to the last line, unless the computer runs across the (extremely frequent) structures that change the control flow, such as conditionals and loops.

For example, imagine a script used to validate user data from a webpage form. The script submits validated data, but if the user, say, leaves a required field empty, the script prompts them to fill it in. To do this, the script uses a conditional structure or if…else, so that different code executes depending on whether the form is complete or not:

if (field==empty) {

promptUser();

} else {

submitForm();

}

The if/else statement is a part of JavaScript’s “Conditional” Statements, which are used to perform different actions based on different conditions.

The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed.

2021-04-27T02:44:00Z

1 Like
  1. What is an expression? A fragment of code that produces a value
  2. What is a binding? It is how a program keeps an internal state and how it remember things
  3. What is an environment? A 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. prompt(“Enter passcode”);
  6. What is a side effect? The concept of a function that can alter the external state of your application, this means that a function can alter parts or values of your application that don’t directly reside inside that same method
  7. Give an example of a function that produces a side effect and another function that produces a value.
    math.max
    math.min
  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? When you 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/else
1 Like

1.What is an expression?
It is a frgment of code that produces a value.
2.What is a binding?
That is a second kind of statement. The special word (keywors) let indicates that this sentence is going to define a binding. To catch and hold values JavaScript provides binding or variable.
3.What is an environment?
It is the collection of bindings and their values that exist at a given time.
4.What is a function?
Is a piece of program wrapped in a value.
5.Give an example of a function.
prompt(’‘Enter your age’’);
6.What is a side effect?
It is showing 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: alert(’‘Danger!’’)
value: Math.min(4,8)
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?
It represents a branching road, where the program takes 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?

Every value that is written literally is an expression. Expressions have a fairly large spectrum, expressions can contain other expressions. An expression can be a binary operator such as + applied to two expressions (values).

2. What is a binding?

A binding lets the program remember things, such as new values created, instead of basically letting them go.

3. What is an environment?

The environment is 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.

prompt is a function.
console.log is a function

6. What is a side effect?

A side effect is what happens when a function returns something, such as a dialog box.

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

The prompt function produces a side effect; a dialog box pop up.
The Math.max function produces a value.

8. What is control flow?

Control flow is the order in which statements are read and executed by the program. In JavaScript, it reads like a story; from top to bottom.

9. What is conditional execution?

Conditional execution is a branch in the program where it will follow a specific path depending on the situation.

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

if is the keyword needed to invoke a conditional execution. It can be complemented with the keyword else.

1 Like
  1. an expression is a piece of code that is a value statement
    2.a binding is a way to capture and contain value
  2. an environment is the set of bindings and their values
  3. a function is a part of a program that is wrapped up in a value
  4. alert (“Call home”);
  5. a side effect is when a function changes the program itself
  6. console.log (“this is a side effect”); let man=false
  7. this is when a program executes in one direction without options
  8. conditional execution is a divided choice in the program on which way it executes
  9. if
1 Like
  1. An expression is a line of code that produces a value.

  2. A binding is used to maintain a value.

  3. An environment is a collection of all bindings and their values existing at the moment in a prompt.

  4. A function is a part of a program contained within a value.

  5. var Aligator = (7 * 20 - (5 + 9))

  6. When a function produces an output that displays to the screen, this is called a side effect.

  7. Example 1: alert(“Hola Mundo!”) Example 2: var y = 4 - 6
    y
    -2

  8. The control flow is the order in which a program is executed.

  9. Conditional execution is when a program can perform and action or another depending upon the conditions met.

  10. The “if” keyword is used to invoke conditional execution.

1 Like
  1. A fragment of code that produces a value is called an expression.

  2. Tentacles created by the keyword Let that create a bond between an expression and its value.

  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

  6. A change the internal state of the machine in a way that will affect the statements that come after it.

  7. . Let a = 10;
    console.log(math.max(a, 130, 238, 162, 10202, 103930));

  8. The path you define to your program do take until it reaches the result you expect.

  9. A path your program takes based on a specific situation that you have previously chose.

  10. If, Else, While,

1 Like
  1. What is an expression? A piece of code that returns a value
  2. What is a binding? A binding catches and holds a value. It does not contain variables, just grasp them before it is disconnected
  3. What is an environment? A collection of bindings and their values that exist at a given time
  4. What is a function? Functions are an expression wrapped in a value, that are executed by calling it
  5. Give an example of a function . alert(“x”)
  6. What is a side effect? A side effect is a change that is made from a statement
  7. Give an example of a function that produces a side effect and another function that produces a value. Let x = 5, console.log(5+5)
  8. What is control flow? The order in which a program is executed
  9. What is conditional execution? When a program follows a certain path depending on the situation
  10. What kind of keyword do you need to use to invoke conditional execution? If, else
1 Like
  1. Expression is a fragment of code that produces a value.
  2. Biding is a keyword used to catch and hold value.
  3. Environment is a collection of biddings and their values that exists at a given time.
  4. Function is a piece of a program within a value.
  5. An example would be an Alert (message).
  6. Side effect is showing a dialog box or writing text to the screen.
  7. Side effect function example: console.log(Math.max(158, 165));
    // - 165
    Value function example: console.log(Math.min(158, 165) + 200);
    // - 358
  8. Control flow happens when a program has more than 1 statement and the statements are executed from like a story from top to bottom.
  9. A conditional execution happens when a program takes a specific action based on the situation in question.
  10. The keywork is “If”.
1 Like
  1. An expression is anything which produces a value

  2. A binding is when a certain tag becomes linked to a value

  3. An environment is all of the tags, functions and expressions contained within a program’s code

  4. A function is a script which takes inputs and produces an output

  5. A + B = C?

  6. A side effect is any function which leaves a variable that will affect the program later on in the code somehow

  7. A + B = C, C+7=?

  8. Control flow means that programs are read from the top down and execute those functions accordingly

  9. Conditional execution means a part of the program will only be executed IF certain conditions are met

  10. IF

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

  2. What is a binding?
    attaching a name that can be considered a constant or a variable to a value

  3. What is an environment?
    a platform in which information such as reserved binding names and user declared bindings are stored with their values

  4. What is a function?
    a program wrapped in a value and can be called upon to be applied in the environment

  5. Give an example of a function.
    function additionMath(arg1, arg2) {
    return arg1 + arg2;
    }

  6. What is a side effect?
    When function has other properties other than returning a value

  7. Give an example of a function that produces a side effect and another function that produces a value.
    example of side effect function: prompt(“Give me a number”,"");
    example of value producing function: console.log(1+2);

  8. What is control flow?
    The precedence of which statement will be executed 1st based on the position of the statement in the environment

  9. What is conditional execution?
    a function in which when the condition is fulfilled, the statement within { } will get executed and if the condition is not fulfilled, it will skip the execution of statements within the { } boundary

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

1 Like
  1. What is an expression?

a fragment of code that produces a value.
every value that is written literally.
Expressions can contain other expressions.

  1. What is a binding?

a variable (place holder); they don’t contain values --> they point to them.

  1. What is an environment?

the collection of bindings and their values that exist at a given time. When a program starts up, the environment is not empty.

  1. What is a function?

a piece of program wrapped in a value.
Executing a function is called invoking, calling, or applying it. Values given to functions are called arguments. Functions may produce values.

  1. Give an example of a function.

prompt(“Enter your name”);

  1. What is a side effect?

Showing a dialog box or writing text to the screen.

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

prompt(“Enter your name”); // side effect

console.log(Math.min(2,4) + 100; // produces a value

  1. What is control flow?

The order in which a computer executes statements: Left to right; Top to bottom.

  1. What is conditional execution?

A program that takes a branch from the “straight road.”

if (execute code IF a certain condition holds)

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

If

1 Like
  1. an expression is some code that produces a value that can be binded to a variable.
  2. a binding is a link between an expression and a variable, to store the value of the expression inside of that variable.
  3. The environment is the set of bindings and their values that exist at a certain time.
  4. a function is a piece of code that can be stored (bind) in a variable. this piece of code can be exectuted by calling the variable name followed by brackets: () Inside of these brackets the caller of the function needs to provide arguments (if needed) to the function. In the end functions return a value which is the result of the computation. If there is nothing explicitly returned it always implicitly returns “undefined”
  5. This function adds 2 numbers a and b together and returns the result:
var addNumbers(a, b){
    return a + b;
}
//shorter syntax using lambdas:
var addNumbers = (a,b) => a+b;
  1. a side effect is some part of the result of a program that is not necessary for the calculation it does. But it is usefull for telling the user the state of the programm.
//side effect:
console.log()
alert()
//value
Maths.max()
  1. control flow describes the order in which commands of a program are being executed. It is always from top to bottom of the file by default, but there are some exceptions. (loops, conditionals, threads)
  2. a conditional execution is an execution that behaves diffrently with respect to some boolean expression:
var random_boolean = Math.random() < 0.5;
if(random_boolean) {
   console.log("Conditional execution A");
} else {
   console.log("Conditional execution B");
}
  1. “if”,“else”, “else if”, “switch”
1 Like
  1. What is an expression?
    Any valid unit of code that resolves to a value; may be a number, string, or logical value

  2. What is a binding?
    holds values, for example created by let, var, const

  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. A set of statements that performs a task or calculates a value

  5. Give an example of a function.
    console.log which prints some output to the console

  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 has side effects because it prints something onto the screen. A function that produces a value…
    function myFunction(a, b) {
    return a * b; }

  8. What is control flow?
    the order that the computer executes statements in a script

  9. What is conditional execution?
    Execution of a script based on the situation at hand

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

1 Like
  1. An expression is a fragment of a code that produces value. Every value that is written literally is an expression.
  2. Binding is when you tag/ reference a variable to a value. Binding don’t hold information but rather grasp them.
  3. The collection of bindings and their values that exist at a given time is called
    the environment.
    4 + 5. 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. Console.log is also an example of function. It is used to output value.
  4. Showing a dialog box or writing text to the screen is a side effect. A lot of
    functions are useful because of the side effects they produce.
  5. Side effect: prompt
    Value: console.log(Math.max(2,4));
  6. Control flow is when your program contains more than one statement, the statements are executed as if they are a story, from a specific order.
  7. Conditional execution is when we want to create a branching road, where the program takes the proper branch based on the situation at hand. Conditional execution is created with the if keyword in JavaScript
  8. ‘‘if’’, ‘‘else’’, ‘‘else if’’
1 Like
  1. An expression is a fragment of code that produces a value

  2. A binding is a variable

  3. An environment is a collection of values and their bindings
    Any bindings that are part of the language standard are always part of any environment

  4. A function is a piece of program with a binding

  5. alert (“hello”)

  6. Showing a dialog or writing to the screen such as in the above example the pop up that says hello is the side effect

  7. square =( x*2) produces the value of X squared(value), prompt (‘insert name’) produces a pop up(side effect)

  8. Control flow is the order in which the program is executed

  9. Conditional execution is when the program splits and carries different executions for certain circumstances

  10. The if keyword is used to create conditional execution

1 Like
  1. What is an expression?

Code that produces a value.

  1. What is a binding?

Something that holds or catches values.

  1. What is an environment?

All the bindings and their values that are active in a given program.

  1. What is a function?

Code wrapped in a value.

  1. Give an example of a function.

prompt(“Welcome to my shop!”);

  1. What is a side effect?

Code and can be as little as something displayed on the screen, or something that affects later statements in your program.

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

Side effect: alert(); because it produces a text box.
Value: Console.log(2+2);

  1. What is control flow?

When code is executed in order from top to bottom.

  1. What is conditional execution?

Code executed only when a certain condition is upheld.

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

If and else to name two.

1 Like
  1. “A fragment of code that produces a value is called an expression”
  2. A binding is a big octopus-style tentacle reaching out, grabbing onto a value. Command of the language gives programmers rule over these monstrously powerful tentacles. The bindings can be made to reach forth and grab at other values. (In some cases, more than one tentacle reaches at the same value. It’s ok to imagine this scenario as a Kraken Fight! :octopus:).
  3. The collection of bindings, along with their values at a given time, constitute what is called the environment.
  4. A piece of program wrapped up in a value is a function.
  5. web3.utils.fromUtf8(“GIMME_A_BYTES32YO”);
  6. Side effects are what we’re calling the consequences of code that triggers an action, changes a value, or sets up changes in how the program will continue to flow.
  7. prompt(“oui”)
    console.log(Math.min(2, 5, 111.11, 12532222/323, -1))
  8. Control flow describes the order in which a program’s functions and instructions are executed and evaluated.
  9. Conditional execution describes a control flow in which decisions about “what to do next” are based on current conditions of the environment as they relate to conditional statements within the program.
  10. if.
1 Like
  1. What is an expression?
    a fragement of code that creates a value
  2. What is a binding?
    A binding is a variable that refrences a value
  3. What is an environment?
    a collection of bindings and their values at a given time
  4. What is a function?
    a piece of a program wrapped in a value
  5. Give an example of a function.
    prompt(“Example”);
  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.
  8. Console.log(Math.max(2, 4));
    4
    Console.log(Math.max(2,4)+100);
    104
  9. What is control flow?
    the order functions or values are executed
  10. What is conditional execution?
    A conditional path for a program depending on the situation at hand
  11. What kind of keyword do you need to use to invoke conditional execution?
    If, else
1 Like
  1. A piece of code that produces a value.
  2. A binding connects a label to a value. i.e. var label = value
  3. A collection of bindings and their values that exist at a given time.
  4. A piece of program wrapped in a value.
    5.Function examples:
  • console.log()
  • A simple function:
functions funcName(x,y){
return x+y
}
  1. A side effect is a function result that does not create a value.
  2. Function that produces a side effect: console.log()
    Function that produces a value: Math.sqrt(x)
  3. Control flow is the sequential, top to bottom order of code execution in javascript. With proper care it could all go on one line.
  4. Conditional execution allows for code to trigger according to a predefined circumstance.
  5. For conditional execution the keywords are if and switch to initiate. For if conditionals else and else if can then be used. For switch conditionals case can then be used.
1 Like