Binding, Functions and Control Flow - Reading Assignment

  • What is an expression?
    An expression is a code fragment that gives a value- anything that gives a value can be referred to as an Expression.
  • What is a binding?
    Binding is a way a programme keeps an internal state Binding is a variable= VAR
  • What is an environment?
    a set of Var and their values
  • What is a function?
    A programme that forms a value is function
  • Give an example of a function.
    alert (" Ivan rocks")
  • What is a side effect?
    Dialogue Box or writing text to the screen.
  • Give an example of a function that produces a side effect and another function that produces a value. Var ( a + b ) Var a =2 Var b =2
    4
    Side effect:
    prompt ( enter you age"); Alexander William
  • What is control flow?
    When your program contains more than one statement, the statements are executed as if they are a story and this is control flow. straight-line control flow
  • What is conditional execution?
    Conditional execution is achieved with the if and else keywords. creation of an external branch.
  • What kind of keyword do you need to use to invoke conditional execution?
    If and Else

1.- What is an expression?
A fragment of code thta produces a value
2.- What is a binding?
Binding is the way to store values in a variable so that we can use it later.
3.- What is an environment?
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.
alert(“this is it”)
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.
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
Writing to a file
Writing to the network
Triggering any external process

console.log(firstAccount);
var firstAccount = account [0];

8.-What is control flow?

The order of execution of the program from top to down

9.-What is conditional execution?
It is the direction 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?

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

to select one of many blocks of code to be executed

Source: w3bschools

  1. What is an expression? A fragment of code that produces a value is called an expression.
  2. What is a binding? To catch and hold values, JavaScript provides a thing called a binding. After a binding has been defined, its name can be used as an expression. The value of such an expression is the value the binding currently holds.
  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. prompt, console.log, Number, Number.isNaN, String, Boolean, etc.
  6. What is a side effect? What is produced when a function is ran.
  7. Give an example of a function that produces a side effect and another function that produces a value. prompt(“Enter passcode”); example of side effect. console.log(Math.max(2, 4)); // → 4 produces a value.
  8. What is control flow? The order in which a program is executed.
  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? Conditional execution is created with the if keyword in JavaScript. In the simple case, we want some code to be executed if, and only if, a certain condition holds.
  1. What is an expression?
    Any piece or fragment of code which produced value is

  2. What is a binding?
    Binding are words creates purposes and holds value for a specific time.
    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 lot of the values provided in the default environment have the type function. A function is a piece of program wrapped in a value. For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input.

  5. Give an example of a function.

typeof 234
“number”
typeof ( true || false)
“boolean”

prompt(“provide account number”)
//dialog shows up

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

  2. Give an example of a function that produces a side effect and another function that produces a value.
    var time = new Date().getHours();
    if (time < 20) {
    greeting = “Good day”;
    } else {
    greeting = “Good evening”;
    }
    alert( ‘I WANT TO BECOME PROGRAMMER’ )

  3. What is control flow?
    The program flows according the construction of your statement. It’s executed as if they are story, from top to bottom.

  4. What is conditional execution?
    Conditional execution is created with the if keyword in JavaScript. In the
    simple case, we want some code to be executed if, and only if, a certain condition holds.

  5. What kind of keyword do you need to use to invoke conditional execution?
    Use ifto 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 to select one of many blocks of code to be executed

:tada::tada::tada::tada:

What is an expression?
  • code that is, or produces a value,
    What is a binding?

  • connection between a value or expression or block of code, and the name given to that value.
    What is an environment?

  • the setting where a program is run. contains all the bindings and running store of the values.
    What is a function?

  • block of re-usable code
    Give an example of a function.

  • block of code here calculates average of 2 values…
    let avg = function(a,b) {
    return (a+b)/2
    }
    What is a side effect?
    side effect is where a function does not return a value. It may modify existing bindings.
    Give an example of a function that produces a side effect and another function that produces a value.

  • this function just prints the average value on the screen:
    let avg = function(a,b) {
    console.log((a+b)/2)
    }

  • this function returns the value which can then be used within the program at a later date:
    let avg = function(a,b) {
    return (a+b)/2
    }
    What is control flow?

  • control flow is the order in which the program statements are run. In it’s most straightforward way this is top to bottom, but can include loops, and function calls etc.

    What is conditional execution?

  • conditional execution is where statements and code blocks are only executed if a certain condition is met. For example if a value is true or false.
    What kind of keyword do you need to use to invoke conditional execution?

  • the ‘if’ key word is the most common way of invoking conditional execution.

1.What is an expression?
An expression is a fragment of code with value(s);

2.What is a binding?
A binding is the same as a variable. You can store and keep values/data in variables/bindings.

3.What is an environment?
The collection of bindings and their values. It is part of the language standard.

4.What is a function?
It is wrapped up code that performe a specific function/task, just like the name indicates.

5.Give an example of a function.
console.log(“Good day to you!”); will print “good day to you!” in the log.

6.What is a side effect?
A side effect is when an expression modifies a state outside its local envoirment. It affects statements that come after it even though it not suppose to or without intention.This happens mostly with global variables if i’ve understood it correctly.

7.Give an example of a function that produces a side effect and another function that produces a value.
alert(“This is a side effect!”); - A code fragment of a side effect.
console.log(“55"); - logs and prints "55” and is/has value. NOT a side effetct.

8.What is control flow?
Basically the order in which the code is executed. From left to right and from top to bottom, just like how we humans read.

9.What is conditional execution?
Conditional execution is when a certain condition is met. depending on the code, if the condiotion is met, something happens/code gets executed and if not, something else happens or no code execution. This will become so much more clear once we get to loops (if loops).

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

  1. An expression occurs when a piece of code produces a value and can be written wherever a value is expected.
  2. Programming will require a vehicle for remembering values. In order to do this JavaScript uses a method called binding. Binding is able to hold a value until that value is changed.
  3. The values that have been declared at a given time are called the environment.
  4. One of the value types of the default environment is a function. The assigned value can be applied in order to run the specific program obtained from the value called function. The book describes it as “a piece of program wrapped in a value”.
  5. Example: alert (“Good Morning”);
  6. A side effect is the product of a function. Showing a dialog box is a side effect.
  7. Side effect function: alert (“Hello world”); Dialog Box
    Value function:
    function myFunction(p1, p2){
    return p1 + p2;
    }
    myFunction (5, 5); Return: 10
  8. Control flow is the order in which the computer executes statements in a script. It is like telling a story in the script from top to bottom.
  9. A program, much like a story, has some twists and turns and does not follow a straight line. In programming this is called conditional execution. Branches appear in the code that modifies the flow of the program. Sometimes even the branches have branches.
  10. When the code uses the word “if: the conditional execution is created. By using “if” the code specifies execution is a condition is true.
    List item

What is an expression?

  • Is a fragment of code that produces a value.

What is a binding?

  • Is giving an element a value to be stored.

What is an environment?

  • Is a collection of bindings and their values.

What is a function?

  • Is a piece of program wrapped in a value.

Give an example of a function.

  • prompt(“What is your name?”)

What is a side effect?

  • Is when a statement changes the internal state of the machine and it affects the statements that come after it

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

  • A function that produces a side effect: prompt(“What is your name?”)
  • A function that produces a value: math.max(2, 4)

What is control flow?

  • Is the order of executing code from top to bottom left to right.

What is conditional execution?

  • Is when the code is executed if, and only if, a certain condition holds.

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

  • if
  1. A section of code that results a value is an expression.
  2. A binding is used to grab and hold a value in the internal state.
  3. A set of bindings and their values at a given time that exists in the memory.
  4. A segment of code that performs an operation and returns a value.
  5. Ex. function area (length, width){
    return area=length*width
    }
    Calling the function,
    area (5,6)

    30

  6. An operation that change/modify the current state and interact with the outside.
  7. Side effect:
    prompt (Number (“enter a number”))
    Value:
    Number (30)
  8. A sequence of step by step operations or instruction from top to bottom. This is similar to a story made of collection of sentences.
  9. A function that performs the operation if and only if the particular condition is met.
  10. if, else, if else
  1. What is an expression?
    Code that produces a value

  2. What is a binding?
    It’s a Variable

  3. What is an environment?
    The collection of variables and their values

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

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

  6. What is a side effect?
    Something a function produces

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side Effect
    prompt(“Enter passcode”);
    Showing a dialog box or writing text to the screen is a side effect.

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

  1. What is control flow?
    It’s the order in which statements are executed

  2. What is conditional execution?
    If Else statements

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

  1. A fragment of code that produces a value, these fragments combine to form statements.

  2. A binding is a reference to some value that we can use to construct statements and hold on to values we can track state of our program and perform work with.

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

  4. A function is a collection of statements tied to a binding that can be invoked by referencing its binding followed by parentheses.

function somethingCool() {
     return "Ice Cream!";
}
  1. A side effect refers to when a piece of code does not return a value, but instead does something else like printing text to the console or displaying a prompt window.

    alert("Hello there!"); //produces a side effect
    Math.random(); //returns a value
  1. Control flow refers to the path execution of statements takes within a program.

  2. Conditional execution allows us to write code that will execute only if some prescribed condition is met.

  3. The if keyword is used to invoke conditional execution, and can be combined with if else and else statements to define many possible conditional branches of execution.

  1. An expression is a fragment of code that produces a value.
  2. A binding catches values and can be used to access those values later. The keywords ‘let’, ‘var’ and ‘const’ define bindings.
  3. An 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. They can be applied or called using parentheses in order to run the program inside the function.
  5. prompt(“Enter Username”);
  6. A side effect is produced if a statement or function changes something other than its return value, for example writing something to the screen.
  7. prompt(“Enter password”); creates a dialog box which is a side effect.
    console.log(Math.max(2, 4)); returns 4 which is a value.
  8. Control flow is when statements execute from the top of a document to the bottom.
  9. Conditional execution determines which sections of code should be run under different conditions.
  10. Conditionals are governed by the keyword if.

Bindings function and control flow

  1. What is an expression?
    A part in the code that gives a value. A value it self is also an expression
  2. What is a binding?
    The Javascript word for variable. But a binding should be considered as a tentacle that grasps the value, not as a box.
  3. What is an environment?
    A collection of the bindings and its values at a certain time.
  4. What is a function?
    A piece a program wrapped into a value.
  5. Example of a function:
    prompt(”xxx”); console.log(x)
  6. What is a side effect?
    When a function shows a dialog box or writes text on screen or something else that is not the main purpose of the function. It works as a kind of help.
  7. Examples
    prompt(”xxx”) gives a side effect; Math.max gives a value.
  8. What is control flow?
    It is in what order every statement in the program executes
  9. What is conditional execution?
    A function that decides what to do in the program depending on given value or condition.
  10. What kind of keyword needed to invoke conditional execution?
    The if-keyword
  1. It is a piece of information that put together creates a value
  2. It is a connection between a variable and its content (value)
  3. It is a set of prewritten bindings that help us with creating new content
  4. It is a piece of code that takes some input parameters, does something with them and spits sout the output value(s)
  5. Math.max(a,b), which compares two numbers a and b and outputs the higher one
  6. It can be for example writing something on the console
  7. Console.log() produces a side effect of writing something on the console, function Math.max() just produces a value
  8. It is influencing the order in which the commands in our code are carried out
  9. It is a command, that gets executed only when a predetermined condition is met
  10. The word if, usually combined with else if and else
  1. Any piece of code that results in value.
  2. When binding, we are assign a specific value to a variable.
  3. All bindings that have been collected.
  4. Piece of programme wrapped in a value.
  5. alert(“Good Morning”);
  6. It alters any expression/function that displays.
  7. prompt(“what is your age”);
  8. An order our programme executes the code.
  9. It means that if a condition is present, programme first evaluates if the condition is met and only then provides an output.
  10. If / Else.
  1. A fragment of code that produces a value.
  2. Binding, or variable catches and holds values ​
  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.
  5. prompt(“Enter passcode”);
  6. Side effects happen when a statement changes the world environment or changes the internal state of the machine and affects the statements that come after it.
  7. Side effect function:
    prompt(“Enter name”);

Value function:
console.log(Math.min(2, 4));
8. Control flow is the order in which the computer executes statements in a program.
9. Conditional execution is where the program takes the proper branch, based on the
situation.
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, or variable is used to catch and hold values in JavaScript.

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

  4. a function is a block of code designed to perform a particular task.

  5. function myFunction(p1, p2) {
     return p1 * p2;              // The function returns the product of p1 and p2
    

    }

  6. A side effect is any application state change that is observable outside the called function other than its return value.( showing a dialog box or writing text to the screen is a side effect.)

  7. console.log side effect is Writing to the screen. and Math.min returns a value.

  8. control flow is the order in which the statements in a script are executed.

  9. conditional execution is when we want some code to be executed if, and only if, a certain condition is true.

  10. conditional execution is created with the if keyword in JavaScript.

1 Like
  • An expression is a piece of code that returns a value. Any piece of code returning a value is an expression
  • Binding is the name given to act of string value in the memory through storing it in a variable.
  • The environment is the collection of all the bindings (stored values) at a given time. Could refer to all the values stored in the memory at that moment for example.
  • A function is a piece of a program that returns a value which can be used as is or by an other function.
  • Example: function date (){return date;}
  • Side effects are consequences triggered by pieces programs that has influence on the program whether or not it can be seen by the user or not.
  • function (a){ console.log(a);} returns a side effect. function (a,b){return a+b;} returns a value
  • Control Flow is the path taken by the computation of the code to be executed.
  • Conditional executions only refers to the conditions set by the programmer to execute the code depending on external factors such as the hardware, software or users actions.
  • The IF keyword will initiate a condition and the result will depend on whether the set condition(s) is/are met or not.
  1. An expression is any valid set of literals, variables, operators, and expressions that evaluates to a single value.

  2. The bind method has several uses. Typically, it is used to preserve execution context for a function that executes in another context. bind creates a new function that has the same body as the original function. The first argument passed to bind specifies the value of the this keyword in the bound function.

  3. The data structure that provides that storage space is called an environment in JavaScript

  4. A function is a JavaScript procedure—a set of statements that performs a task or calculates a value.

  5. function myFunction(a1, a2){
    return a1 * a2;
    }

  6. A side effect is any application state change that is observable outside the called function other than its return value.

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

Value:

(see #5)

  1. The control flow is the order in which the computer executes statements in a script.

  2. Executes if some condition is met.

  3. if, else, else if

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

  2. What is a binding?
    Allows you the attach or tag a value to a variable or state

  3. What is an environment?
    Collection of values and bindings 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(“hello you”)

  6. What is a side effect?
    Any application state change that is observable other than the returning value that is triggered by executing a function

  7. Give an example of a function that produces a side effect and another function that produces a value.
    prompt(“enter your age”)
    console.log(math.max(3,9))

  8. What is control flow?
    The order in which the computer executes statements when there are more than one. Usually executed in a story format.

  9. What is conditional execution?
    branching path that the program takes based on the conditions fulfilled/situation

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