Binding, Functions and Control Flow - Reading Assignment

[quote=“ivan, post:1, topic:3069, full:true”]
Welcome to the discussion about the reading assignment about Binding, Functions and Control Flow.

Leave your answers to the questions below in this thread. If you have any questions or you want to discuss something connected to the assignment feel free to do it in this thread as well, but please everything to the topic.

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

  2. What is a binding?
    Binding catches and holds values. They can be used to file pieces of data under a name, and they are useful for tracking state in your program.

  3. What is an environment?
    An 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. Such value can be applied in order to run the wrapped program.

  5. Give an example of a function.
    The console.log function.

  6. What is a side effect?
    A side effect 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.
    Side effect function: makeNoice; value function: console.log, square.

  8. What is control flow?
    Cost flow is the order in which statements are executed in a program.

  9. What is conditional execution?
    Condition execution/statement is used to decide the flow of execution based on different conditions.

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

1 Like
  1. What is an expression?
    A fragment of code that produces a value.
  2. What is a binding?
    Binding allows the user to catch and hold values.
  3. What is an environment?
    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.
    var x=2; var y=4; console.log(“The sum of x and y is”,(x+y));
  6. What is a side effect?
    It´s the result of changing the function in a way that the following statements will be afected by that change;
  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side effect function- var input= prompt(“Hello World!”);
    Produces value function- var x=2; var y=4; console.log(“The sum of x and y is”,(x+y));
  8. What is control flow?
    Control flow is the sum of statements executed in a hierarchically order, from top to bottom.
  9. What is conditional execution?
    Conditional execution is executed when the keyword If exists, giving orders to the programm only when certain conditions holds.
  10. What kind of keyword do you need to use to invoke conditional execution?
    If keyword.
1 Like
  1. A fragment of code that produces a value.
  2. Catches and Holds Values.
  3. A collection of bindings and their values that exist at a given time.
  4. Several values in the environment have a function or piece of program wrapped in a value.
  5. console.log
  6. Return value or dialog box or writing text on the screen.
  7. prompt (“HI”); and console.log (1+1);
  8. Guidelines on executions of statements which in this case are top to bottom.
  9. Not all executions or programs are straight roads, there could be a branch based on a situation and as such a conditional execution.
  10. IF
1 Like
  1. What is an expression?
    An expression is a fragment of that produces a value.

  2. What is a binding?
    A binding allows Javascript to keep an internal state and remember a value. The keyword (let) indicates that this sentence is going to define a binding.

  3. What is an environment?
    An environment 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 that are applied in order to run the wrapped programs. They interact with loaded websites and are used to read mouse and keyboard inputs

  5. Give an example of a function.
    An example of a function would be

prompt("Enter your password");
  1. What is a side effect?
    A side effect is a change in the internal state of the machine that changes a statement.

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

prompt("Enter your Date of Birth");
console.log(a+b*2);
  1. What is control flow?
    Control flow is when your program contains more than one statement, the statements are executed from top to bottom.

  2. What is conditional execution?
    A conditional execution is created by using the “if” keyword. This is used when one what to have some code be executed if, and only if, a certain condition holds.

  3. What kind of keyword do you need to use to invoke conditional execution?
    Keywords that invoke conditional execution are :

if
else
else if

1 Like
  1. A fragment of code that produces a value is called anexpression.
  2. A binding (or variable) catches and holds a 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. In a browser environment,the binding prompt holds a function that shows a little dialog box asking for user input.
  6. Showing a dialog box or writing text to the screen is aside effect.
  7. The prompt function produces the side effect of requesting an input from the user. The function Math.max produces a value.
  8. The sequence in which statements are executed is control flow.
  9. Conditional execution occurs when the program makes a decision as to which code to execute next.
  10. If.
1 Like
  1. An expression is a fragment of code that produces a value.

  2. A binding is what allows a program to catch and hold value designations. It’s also known as a variable.

  3. An environment is the collection of bindings and their values as they exist at any given time.

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

  5. An example of a function is a browser using a ‘prompt’ function to request the user to enter his/her passcode.

  6. A side effect is what we call a ‘change’ produced by a significant enough ‘statement,’ that produces a detectable/measurable difference (regardless of how big or small) in the world.

  7. An example of a function that produces a side effect and another function that produces a value is, the console.log function, which produces values; vs, the prompt function which produces a side effect.

  8. Control flow is the order in which a program executes the statements it contains. Typically executed as a story being read from top to bottom.

  9. Conditional execution is when a program does not execute it’s statements in a straight line; rather, more of a branch execution based on variables/conditions being met per instructions by the programmer, based on inputs by the user.

  10. To invoke conditional execution, the kind of keyword you need is, “if,” and/or if/else combos.

1 Like
  1. What is an expression?
    A fragment of code that produces a value. Expressions can be nested in other expressions.
  2. What is a binding?
    Variable. Assigning value to memory.
  3. What is an environment?
    The collection of bindings and their values that exist at a given time
  4. What is a function?
    Transform or manipulate input vales to output values. Specifically, manipulate the enviroment.
  5. Give an example of a function.

prompt(“Enter passcode”);

  1. What is a side effect?
    Change the internal state of the machine in a way that will affect the statements that
    come after it
  2. Give an example of a function that produces a side effect and another function that produces a value.
    function square(x) {
    return x * x;
    }

function value {
1!;
}
8. What is control flow?
The order in which statements are executed or evaluated.
9. What is conditional execution?
The program decides which path/brand to take.
10. What kind of keyword do you need to use to invoke conditional execution?
if, else if and else

1 Like
  1. A fragment of code that produces a value.

  2. Bindings are used to catch and hold values.

  3. It is the collection of bindings with their values to a given time.

  4. It is a value with a piece of programm inside.

  5. Prompt() is a function, which shows a dialog box for user input.

  6. A dialog box shown or written text on the screen is called side effect.

  7. Functions with prompt() give side effects and with console.log(Math.max()) you get a value based on any amount of arguments inside, giving back the greatest value.

  8. Control Flow determines the sequence the functions will be solved in a programm. If there are more than one statment, they will be executed from top to bottom.

  9. Conditional execution describes branches inside a programm, which will be then choosen based on situation and condition, because a programm may be not allways a straight road.

  10. “If” can used as a keyword. You need keywords that execute or skip the statements depending on the value given.

1 Like
  1. A fragment of code that produces a value.
    2.This is an instruction that tells the variable what to remember / contain.
  2. An environment is the current collection of values and bindings present.
  3. A function is a piece of programming or a sequence of instructions contained within a value.
  4. The prompt command holds a function that displays a dialogue box with an input field.
  5. A side effect is the result of a program that occurs that is not its primary goal or function. In other words, if the function modifies the state of something else outside its own scope, then it is causing a side effect.
  6. Alert is a function that produces a side effect and console.log(1 + 2) is a function that produces a value.
    8.Control flow is the way in which the computer evaluates and executes multiple lines of code.
  7. Conditional execution gives functions or code conditions that are required to be met or not met in order for the code to run. With this we can create multiple possible outcomes based on the situation.
  8. If, else
1 Like
  1. What is an expression?
    An expression is a portion of code that produces a value.
  2. What is a binding?
    Binding is an expression that binds an object to a function. It retains a stored value to be called ant any time.
  3. What is an environment?
    An environment is the collection of bindings, statements and functions within the general use of the code.
  4. What is a function?
    A function is an expression in the code that performs a task within the environment when called upon. There are set functions within the language but they can also be created.
  5. Give an example of a function.
    function myFunction(p1, p2) {
    return p1 * p2; // The function returns the product of p1 and p2
    }
  6. What is a side effect?
    A side effect is a function that alters parts or values outside of the general environment.
  7. Give an example of a function that produces a side effect and another function that produces a value.
    function some_process() {
    const data = get_data_somehow();
    const clean_data = computation(data);
    const result = save(clean_data);

return result;
}
8) What is control flow?
Control flow is the direction the program is statements are read are from top to bottom.
9) What is conditional execution?
A conditional execution is when there can be more than one program procedure can be ran and is based on a specific value or condition.
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 catches and holds a value e.g. variable
  3. An environment is a collection of bindings and their values at a given time.
  4. A piece of program wrapped in a value that can interact and used to read mouse or keyboard inputs.
  5. prompt(“enter password”);
  6. Functions produce side effects such as a dialog box or writing text to screen
  7. Side effect function: prompt(“What is you name?”);
    Value producing function: console.log(Math.max(2, 4));
  8. When programs contain more than one statement, the statements are
    executed as if they are a story, from top to bottom.
  9. A program has a branching road and which path is taken depends on the situation at hand.
  10. if
1 Like

1- An expression is a total thought that resolves a problem.
2- A bindiong is equal to a variable. (stores info)
3- a place that variable hold the info (values)
4- a command that performs a task.
5- alert(“show this function”);
6- a unplanned reaction to a function
7- when using console.log it produces a side effect and Math.max produces a value.
8- Order of operations.
9- Execution if perimeters are met.
10- IF, ELSE

1 Like
  1. What is an expression?

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

  1. What is a binding?

Binding is a variable, it is a way for the program to keep an internal state that stores values that can be used later.

  1. What is an environment?

The collection of bindings and their values that exist at a given time is called the environment

  1. What is a function?

A function is a piece of program wrapped in a value

  1. Give an example of a function.

prompt(“tell me more”);

  1. What is a side effect?

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

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

side effect example:

prompt(“Enter your name”);
value Joe
console.log(Math.max(2, 4));
it will output a value that is 4
Side effect is kind of action that is performed in an environment but value is a result that is displayed by a function via return.

When a function produces a value, it is said to return that value.

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

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

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

if, else,

1 Like
  1. A fragment of code that produces a value

  2. To catch and hold values

  3. The collection of bindings and their values that exist at a given time (binding)

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

  5. console.log to output values

  6. a method which modifies some state variable value, passed having a consequence beyond its scope

  7. Console.log for values and Console.log(Math.min(2, 4) + 100); (Math.max(2, 4))

  8. Flow is basically the statements within your program, Javascrip will execute it as a story.

  9. a branching road, where the program takes the proper branch based on the situation at hand.

  10. A conditional execution is invoked with the keyword if.

1 Like
  1. A fragment of code that produces a value is called an expression.
    If an expression corresponds to a sentence fragment, a JavaScript statement
    corresponds to a full sentence. A program is a list of statements.
    The simplest kind of statement is an expression with a semicolon after it.

  2. To catch and hold values, JavaScript provides a thing called a
    binding, or variable(let/var/const(constant)).Binding is a way, a program keeps an internal
    state. Binding stores value so that we can use it later.

  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. Such values can be applied
    in order to run the wrapped program.

  5. prompt(“How are you?”); or alert(“Welcome”);

  6. A statement that cause the change of 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. Function producing side effect: console.log ; Function producing a value: Math.pow.

  8. Control flow is simply the order in which we code and have our statements evaluated. It is the direction of execution of code in JavaScript which happens in a top down approach.

  9. It means that the code is only executed when the statement provided, meets/agrees with the predefined condition.

  10. IF

1 Like
  1. What is an expression?
    -A fragment of code that produces a value. Defined binding names may be used as expressions.
  2. What is a binding?
    -Bindings, or “tentacles,” are used to catch and hold values Ex. let
  3. What is an environment?
    -The collection of bindings (contains bindings that are part of the language standard, and those that provide ways to interact with the system) and their values that exist at a given time.
  4. What is a function?
    -Piece of program wrapped in a value, so that it may be applied in order to run a wrapped program. Ex. prompt
  5. Give an example of a function.
    -function greet() {
    console.log(“Hello World”);
    Input: greet()
    Output: Hello World
  6. What is a side effect?
    -Code that will cause changes in state after execution.
    ex. Omission of a key word like var in local context, creating a global variable
  7. Give an example of a function that produces a side effect and another function that produces a value.
    -Side Effect:
    (function() {
    // no var keyword, so global variable created
    mono = ‘monkey’;
    })();
    -No side effect:
    (function() {
    var mono = ‘monkey’;
    })();
  8. What is control flow?
    -When a program contains more than one statement, the statements are executed as if they are a story, from top to bottom, this is straight-line control flow.
  9. What is conditional execution?
    -Creating a statement branch or branches that execute based on if the given situation at hand meet(s) predefined criteria.
  10. What kind of keyword do you need to use to invoke conditional execution?
    -If, else.
1 Like
  1. code that produces a value
  2. assignment of value to variable
  3. " The collection of bindings and their values that exist at a given time is called the environment . When a program starts up, this environment is not empty."
  4. a way of mapping inputs to a unique output–or a set of ordered pairs–sometimes combined with a domain and range–these are the ‘intensional’ and ‘extensional’ definitions, respectively
  5. the square root function–its domain is POSITIVE
  6. a result of running a function other than what is done with its return value
  7. the whole point of console.log is its side effect, compare to Math.sqrt
  8. how the current line of execution in the source code changes–it’s not always to the next line
  9. only executing certain code under certain (boolean) conditions
  10. ‘if’
1 Like

What is an expression?
Expression is a piece of code that produces a value. Anything that produces a value is an expression.
What is a binding?
Binding or variable is a thing that provides catching and holding value.
What is an environment?
The collection of bindings and their values that exist at a given time.
What is a function?
It’s a piece of program wrapped in a value like for example function prompt. We can give the function values called arguments and than invoke/execute or call that function.
Give an example of a function.
Number.isNaN(); or prompt();
What is a side effect?
It’s any app state change that is observable outside the called function other than its return value.
Give an example of a function that produces a side effect and another function that produces a value.
a side effect produces function prompt();
a value produces Math.max();
What is control flow?
It’s a way of executing of statements in program (more than one statements). Statements are executed like a story from top to bottom.
What is conditional execution?
Conditional ececution is a case when we want to execute some code but if, and only if, a certain condition holds.
What kind of keyword do you need to use to invoke conditional execution?
if keyword

1 Like
  1. A fragment of code that produces a value.
  2. Binding allows a variable to catch and hold a value.
  3. The collection of bindings and their variables existing in a given time.
  4. A piece of a program wrapped in a value.
  5. The ‘prompt’ function within a web browser can provide a dialog box to retrieve a user input.
  6. A side effect of a function can provide usefulness, however, a function may be used to produce values instead of printing to the console as an example.
  7. console.log()
    Math.max(x,b)
  8. The order of execution in a program (top to bottom).
  9. The order of execution can change and omit certain portions depending on the conditional status of the program.
  10. if
1 Like

1.) Any part of the code that creates some kind of a value.
2.) Binding is another name for a variable, which is an allocated part of the memory that stroes a previously specified value.
3.) Environment is a collection of bindings and their values.
4.) A small piece of program, assigned to a value.
5.) Math.max()
6.) A programs side effect is the ability to change something that will affect how latter parts of the program will behave.
7.) alert(“something”) produces a side effect, Math.max(1, 2) produces a value.
8.) Control flow is the order in which the program executes the orders.
9.) Conditional execution means, that a certain part of the program will only run if a certain, well defined condition applies.
10.) if

1 Like