Binding, Functions and Control Flow - Reading Assignment

  1. An expression is fragment of code that results in a value.

  2. A binding or a variable is assignment of internal state used to catch and hold values.

  3. The environment is the collection of bindings and their values existing in a given instance.

  4. A function is an expression wrapped in a value. It can be executed by calling it.

  5. Alert(“Hello world!”);

  6. A side effect is where a function does something other that return a value such as writing to the screen or displaying a prompt or a dialog box.

  7. alert(“Hello world!”);
    console.log(1 + 2)

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

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

  10. If, else, while or loop.

  1. An expression is a fragmented piece of code that can produce a value, which can be of three types:
    a. Numeric
    b. String
    c. Function
  2. A binding or variable enables us to attach and hold something to a value. Usually we give a name to a binding for reference.
  3. An environment is the collection of all our bindings and values.
  4. A function is a value that contains a program. Usually we envoke/call a function in order to run the program it holds.
  5. let name = “What is your name?”;
    console.log(name);
  6. In order to understand what a side effect is we must first understand 3 things:
    a. An expression is like a single word in a sentence
    b. A Statement is like the complete sentence
    c. Programs are made of a list of Statements.
    So, whenever a statement can effect the inner state of a program by altering its’ next statements, this is what is called a side effect.
  7. A. Function producing a Side effect(because it produces a pop up dialogue box on the screen)
    alert(“What is your name?”);
    B. Function producing only a Value
    console.log(Math.max(2, 4));
  8. Control flow is the way our program executes our statements (from top to bottom).
  9. Conditional execution means that a program will continue or not based on if a certain condition is met.
  10. If…

What is an expression?
a fragment of code that produces a value
What is a binding?
its a connection from a variable to its value that holds.
What is an environment?
the collection of bindings and their values at the moment
What is a function?
a piece of program that performs a specific task

Give an example of a function.
document.write(“I hope this is it”);
What is a side effect?
change of an observable statement of a program
Give an example of a function that produces a side effect and another function that produces a value.
alert(“this is a side effect”);
console.log(a+5); it produces a value
What is control flow?
is the way of executing the program, it goes from top to bottom
What is conditional execution?
when we have an execution based on some conditions (do something if …else…)
What kind of keyword do you need to use to invoke conditional execution?
if keyword

  1. A fragment of code that produces a value is called an expression.
  2. To catch and hold values, JavaScript provides something called a binding, or variable.
  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. alert(“Will the Real Slim Shady please stand up?”);
  6. Showing a dialog box or writing text to the screen is a side effect.
  7. alert(“Prepare for WW3”); --> produces a side effect
    console.log(Math.max(2, 4)); --> produces a value
  8. When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom. This is called the control flow of a program.
  9. 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. if is the keywork to invoke a conditional execution.
  1. An expression is a fragment of code that produces a value.

  2. A binding is a variable.

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

  5. An example of a function is the alert() command.

  6. Side effects are changes to the world as a result of statements. “Showing a dialog box or writing text to the screen is a side effect.”

  7. A function example that produces a side effect: alert(“hi”);
    A function example that produces a value: (Math.max(10, 100) + 5);

  8. Control flow is the order in which statements are executed in a program.

  9. Conditional execution is when a statement’s execution is dependent on a certain condition.

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

  1. an expression is a fragment of code that produces a value
  2. a binding is to catch or hold a value such as a variable
  3. an environment is a collection of bindings and their values
  4. a function is a piece of program wrapped in a value
  5. an example of a function would be: prompt(“enter passcode”);
  6. a side effect is writing text to a screen or showing a dialog box
  7. one that produces a side effect is prompt(“enter passcode”); and one that produces a value is console.log(math.max(2, 4));
  8. control flow is when a program is executed from top to bottom
  9. a conditional execution is when a program is executed based on the situation at hand
  10. if
  1. Any fragment of the code that can stand on its own.
  2. Is a way the program uses to remember things by “binding” the desired value to a keyword. This are called also “variables”.
  3. As the text says, is “the collection of bindings and their values that exist at a given time”.
  4. A part of the code that usually works with other parts of the codes and variables, that’s why is said that is “wrapped in a value”.
  5. alert(“this is a function”);
  6. Is when a function produces a change inside the machine, and this change could affect the rest of the code willing or unwillingly.
  7. • Side effect:
    o var a = 1, b = 2;
    • Value production:
    o console.log(a + b);
  8. Is how we attempt to make the code progress, we have to decide in what order are executed the expressions and within which rules one must move to the next.
  9. Is when we have several options to move to the next statement depending on the outcome of the current statement.
  10. For JavaScript, the keyword to begin the conditional is if, and to decide the paths are else if and else.

What is an expression?
A fragment of code that produces any value.

What is a binding?
It is the operation of assign a value to a given name

What is an environment?
A collection of all variables defined

What is a function?
A piece of code wrapped in a value that can executed any time

Give an example of a function.
alert, prompt, console.log

What is a side effect?
A operation which can affect the execution of a program

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

let age = 12

const sideEffect = function () {
  age = 23;
}

const value = function () {
  return 23;
}

age = value()

What is control flow?
It is a mechanism to control the execution of statements

What is conditional execution?
A statement or block of statements that can be executed depending on a condition declared

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

1. What is an expression?

A fragment of code that produces a value is called an expression. Every value
that is written literally 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

2. What is a binding?

binding ensure a program maintain its internal state, thus able to catch and hold values in JavaScript. Bindings as tentacles, rather than boxes. They do not contain values; they grasp them—two bindings can refer to the same value. A program can access only the values that it still has a reference to.

3. What is an environment?

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. It always contains bindings that are part of the language standard, and most of the time, it also has bindings that provide ways to interact with the surrounding system.

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.

5. Give an example of a function.

prompt(“Enter passcode”);
alert (“hello world”)

6. What is a side effect?

An expression can be content to just produce a value, which can then be used by the enclosing code. A statement stands on its own, so it amounts to something only if it affects the world.
These changes are called side effects. 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. Functions may also produce values, in which case they don’t need to have a side effect to be useful.

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

alert (“hello”)produce side effect, console.log(Math.min(2, 4) + 100)produce a value.

8. What is control flow?

control flow is the sequence of Javascript process statements. 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 program execute in a straight line fashion, but sometimes 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?

Conditional execution is created with the if keyword in JavaScript.

if (condition1) {
    block of code to be executed if condition1 is true
} else if (condition2) {
    block of code to be executed if the condition1 is false and condition2 is true
} else {
    block of code to be executed if the condition1 is false and condition2 is false
}
  1. An expression can be any number or any letter
  2. A binding is a way to store the value of a expression
  3. An environment is a collection of bindings and there values
  4. A function is a piece of a programm wrapped in a value
  5. prompt(“Enter your name”)
  6. Side effect is a function that produce an expression an return that value. Can be the message appeared on the screan or a pop-up
  7. alert(“Hi”);
    and
    console.log(2*4)
  8. When your program contains more than one statement, the statements are executed in the stored order. From top to bottom
  9. Conditional execution is the way that programs take the proper branch based on given instructions.
  10. if, else if, else

1.An expression is group of operators and variables that evaluates to a value.

2.Holding a value in an identifier or a variable is binding.

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

4.A program wrapped in a value.

  1. sum(a,b)
    {
    return a+b;
    }

6.A side affect happens when a statements in a program affect other statements that come after
that statement and also affect the internal state of the machine.

  1. Number.NaN()----->produces side effect
    sum(a,b)

8.A control flow is used to direct the flow of a program to specific blocks of statements
based upon the conditions given in conditional statements.

9.Depending on the conditions given in If statements,a group of statements are executed.

  1. If,While keywords are used.
1 Like

Reading Assignment - Binding, Functions and Control Flow

  • What is an expression?
    • “A fragment of code that produces a value is called an expression.
      Every value that is written literally (such as 22 or “psychoanalysis”) is an expression.”
  • What is a binding?
    • A binding is a synonym for a variable. It can remember a value or it can be changed later. An expression produces a value, bit it has to be used by the surrounding code. A binding can hold that value for later use. Javascript uses the “Let” statement to create a binding.
  • What is an environment?
    • The collection of bindings and values existing at a particular time is called the environment. This also includes default values of bindings, including functions in the Javascript language and values from the “surrounding system” or the web browser and the website.
  • What is a function?
    • A function is “a piece of program wrapped in a value”
    • An example of a function is the binding prompt, used like this: prompt("Enter passcode");
  • What is a side effect?
    • A side effect is anything that a function does, other than producing a return value.
    • An example of a function that is called *only for its side effect is print();
      which launches a print dialog box with the default settings, to print the current web page.
    • Examples of functions that produces a side effect and a value is prompt("foo")
      producing a prompt in which I typed “bar”, and it returned that value; and console.log() outputting its results to the console.
    • An example of a function that produces a value ONLY, that is “a pure function” is zeroPad() in the following example:
      function zeroPad(number, width) { let string = String(number); while (string.length < width) { string = "0" + string; } return string;
  • What is control flow?
    • Control Flow is the order in which statements are processed, for example, from top to bottom.
  • What is conditional execution?
    • Conditional Execution is where alternative paths, or branches of code might be processed, depending on the evaluation of conditional, or boolean logic.
    • The “if” keyword invokes conditional execution.
1 Like

1. What is an expression?
A fragment of code that produces a value is called an expression. 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.

2. What is a binding?
Binding is a statement that catches and holds values.

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.

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”);

image

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.
Example that produces a value:
console.log(Math.max(2, 4));
// → 4

Example that produces a side effect;
alert(“Giorgos”);

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?
If we want to create a branching road, where the program takes the proper branch based on the situation at hand, then this is called conditional execution.

10. What kind of keyword do you need to use to invoke conditional execution?
Conditional execution is created with the “if” keyword. If we want to have more than 2 outcomes, then we use the keyword “if” and then the keyword “else”.

  1. An expression is a fragment of code that produces a value.
  2. A binding enables a value to be assigned to and element and recalled in other parts of the code.
  3. An environment is the collection of bindings and their values that exist at a given point in time.
  4. A function is a piece of program that is wrapped up in a value.
  5. prompt, Number
  6. A side effect occurs when a function executes and produces a “mark on the world”, as opposed to simply producing a value. E.g. Writes text to screen or shows a dialog box.
  7. A function that produces a side effect is: prompt. A function that produces a value is: Math.max
  8. Control flow governs the sequence in which statements are executed.
  9. Conditional execution creates alternative execution path(s) that are only executed if their conditional requirement is met in relation to an associated previous result.
  10. if, else
1 Like

1. What is an expression?
2. What is a binding?
3. What is an environment?
4. What is a function?
5. Give an example of a function.
6. What is a side effect?
7. Give an example of a function that produces a side effect and another function that produces a value.
8. What is control flow?
9. What is conditional execution?
10. What kind of keyword do you need to use to invoke conditional execution?

What is an expression?

  1. A fragment of code which produces a value. Possible to contain other expressions within an expression. Allows for an increasing level of complexity. Expression = sentence fragment, statement = full sentence. Program = list of statements.
    What is a binding?
    2. A binding is a type of statement. Allows computer to hold sentences in memory for longer.
    Also known as a variable
    Notation is let x = y
    Where x is the name of the binding and y is an expression.
    Name of binding can be used as an expression once defined.
    Expression connected to any binding can be changed at any time by pointing the binding somewhere else.
    Can use var instead but has unusual properties.
    Can’t use a keyword (such as let) or a reserved word as a binding.
    What is an environment?
    3. The collection of bindings and variables that exist within the program.
    This includes whatever the programmer has written plus existing bindings/functions included within the program or part of the surrounding system.
    What is a function?
    4. Something that performs an action on an expression.
    A piece of program wrapped in a value.
    Value applied to run the program.

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

What is a side effect?
6. A side effect is where the statement changes the statements that come after it.
Functions are often useful due to the side effects they create – e.g. something being printed on the screen.

Give an example of a function that produces a side effect and another function that produces a value.
7. (Math.max(x, y)); produces a value.
Alert produces a side effect.

What is control flow?
8. The order in which the program is executed. Which is the same as reading a book; top left to bottom right.

What is conditional execution?
9. There might be several ‘routes’ that the program could run depending on inputs. The direction of the route can be decided using ‘if’.

What kind of keyword do you need to use to invoke conditional execution?
10. If
If else
If (!number.NaN(number));{

1 Like

1. What is an expression? Any fragment of code that produces a value is called an expression

2. What is a binding? A binding is a reference to some value stored in memory that can be accessed later on by its name

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

5. Give an example of a function.

  • console.log

6. What is a side effect? Outputting to a display or altering the internal state of the machine in a way that will affect the statements that come after it are called side effects.

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

  • Prompt(“Enter passcode”); produces a side effect
  • Math.max(2, 4); produces a value

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

9. What is conditional execution? Conditional execution occurs when parts of the code is only executed after a certain condition is met

10. What kind of keyword do you need to use to invoke conditional execution? Conditional execution is created with the ‘if’ keyword

1 Like
  1. An expression is anything that produces a value.
  2. Binding is a variable, which catches and holds values.
  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.
  5. Function example: alert(“Hello\nHow are you?”);
  6. Side effect shows something on the screen or it changes the internal state of the machine.
  7. An example of a function that produces a side effect: document.write(Date());
    An example of a function that produces a value: Math.floor(4.7);
  8. Control flow is an execution of the statements from the top to bottom.
  9. Conditional execution is the execution in a case that a certain condition holds.
  10. To invoke conditional execution use “if” keyword.
1 Like

What is an expression?
A fragment of code that produces a value is called an expression.
What is a binding?
Binding is how variables are declared and eventually assigned a value at the same time. Bindings are created by using the keywork “let”.
What is an environment?
The set of variables and functions define the environment
What is a function?
a piece of code that can be reused. it can accepts parameters as input and returns a value as output
Give an example of a function.
prompt(“Enter your name”);
What is a side effect?
When a function produces something else than a value. It’s a side effect.
Give an example of a function that produces a side effect and another function that produces a value.
prompt(“Enter your name”); -> causes a prompt message box to appear on the screen that is a side effect.
math.max(7,2); -> output the value 2 which can be used as part of another expression.
What is control flow?
Java Script is executed from top to bottom and the code controls the flow of he program.
What is conditional execution?
when you only execute part of your code under certain conditions.
What kind of keyword do you need to use to invoke conditional execution?
if

1 Like
  1. anything that produce value
  2. used for holding values
  3. collection of bindings and their values
  4. piece of program design to do specific things
  5. function multiply(a,b){return a*b;};
  6. showing a dialog box or writing text to the screen
  7. value = function multiply(a,b){return a*b;};
    side effect = function hello(){console.log(“Hello!”);};
  8. when program contains more than one statement
  9. do one thing or another
  10. if else
  1. What is an expression?
    A fragment of code that produces a value is called an expression. Every value
    that is written literally 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. Expressions can contain other expressions in a way similar to how subsentences in human languages are nested—a subsentence can contain its own subsentences, and so on. Anything that produces a value is an expression in JavaScript,

  2. What is a binding?
    JavaScript provides a binding, or variable to catch and hold values. The keyword let indicates that a sentence is going to define a binding. It is followed by the name of
    the binding and, if we want to immediately give it a value, by an = operator and an expression. 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.
    The words var and const can also be used to create bindings, in a way similar to let.
    var does mostly the same thing as let, but it has some confusing properties. The word const stands for constant. It defines a constant binding, which points at the same value for as long as it lives

  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. It’s a building block in a program.

  5. Give an example of a function.
    Some examples: console.log, Math.max, Number.isNaN. Of course you wan and will write your own functions.

  6. What is a side effect?
    Showing a dialog box or writing text to the screen are examples of a side effect. The function may return a value, but causes an “event” as showing a dialog box. A lot of functions are useful because of the side effects they produce. Functions may also produce values, in which case they don’t need to have a side effect to be useful.

  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: console.log
    Function that produces a value: 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. 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. In following chapters we will learn other ways to control the flow, for example with loops.

  9. What is conditional execution?
    In the simple case, we want some code to be executed if, and only if, a certain condition holds. You often won’t just have code that executes when a condition holds true, but also code that handles the other case. You can also have more than two paths to choose from.

  10. What kind of keyword do you need to use to invoke conditional execution?
    Conditional execution is created with the if keyword in JavaScript. You can use the
    else keyword, together with if, to create two separate, alternative execution paths. If you have more than two paths to choose from, you can “chain” multiple if_/_else pairs together.