Binding, Functions and Control Flow - Reading Assignment

1- Is a fragment of code that produces a value. Every value that is written is an expression.
2- Is something to catch and hold values.
3- Is a collection fo bindings and their values that exist at a given time.
4- Is a piece of program wrapped in a value.
5- alert (“Hello world”).
6- A side effect is showing a dialog box or writing text to the screen.
7- alert (“Hello World”) // console.log (Math.max(1, 2, 3, 100)).
8- Is the way the statements are executed, like a story, from top to the bottom.
9- The program takes the proper branch based on the situation at hand.
10- if // else

2 Likes
  1. Expressions are the result of values and operators

  2. Binding attaches a value / expression to a binding name that can be used to recall that information later on. Bindings are like tentacles and can be attached to a different value / expression

  3. A collection of bindings and values that exist together at any given time

  4. Is a small programme wrapped up in a value

  5. prompt(“What is this question asking?”)

  6. Is when a function interacts with it’s environment

  7. prompt displays a dialog box in the browser - this is a side effect of the function. Math.max returns a value based on the argument you give it - e.g Match.max(2, 4) returns 4 as it is the highest of the 2 arguments.

  8. How a programme is executed - it is always top to bottom (start to end)

  9. When a block of code is executed only if a condition is met - one example is using the IF keyword with a conditional operator such as < or >.

10.IF.

2 Likes
  1. An expression is a small portion of code that produces a value.
  2. A binding(variable) is used to connect two values and store the relationship.
  3. An environment is a collection of bindings and their values at a specific time.
  4. A function is a piece of program wrapped in a value.
  5. An example of a function would be console.log
  6. A side effect is visible change in the state of an application.
  7. console.log is a function that returns a value
    alert would be a function to produce a side effect
  8. Control flow is when a program consists of multiple statements, they are written as a story, from top to bottom.
  9. Conditional execution is when you might want to create a branch based on the situation
  10. Keywords that could be used to invoke conditional execution may include if, else, while, loop, true/false
2 Likes
  1. Every value that is written is an expression.
    2.to catch and hold a value by assigning keyword is called binding or variable
    3.The collection of bindings/variables and their values that exist at a given time is called environment.
  2. A function is a piece of a program wrapped in a value
  3. Let thenumber= Number(prompt(“Pick a number”));
    console.log("Your number is the square root of " + thenumber * thenumber);
  4. Showing a dialog box or writing text to the screen is a side effect
  5. console.log(Math.ma(2,4));
    // 4
  6. when a program contains more than one statement, the statement are executed as if it is a story, from top to bottom.
  7. a branch based on the situation at hand called the conditional execution
  8. If and else condition
2 Likes

1. What is an expression?
an expression is a piece of code that returns a value.

2. What is a binding?
Binding are like tentacles, as in they do not hold any information, but it goes out to grabs (binds) the information.

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

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?
A statement or function that modifies the state of something outside its own scope is producing a side effect.

7. Give an example of a function that produces a side effect and another function that produces a value.
Side Effect: alert(“Hey what’s up”)
Function: Consol.log(5+5)

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

9. What is conditional execution?
Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run.

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

2 Likes
  1. What is an expression?
    Any line of code that consist of values and or operators.

  2. What is a binding?
    A function or keyword keeps connection to a value to store it for later usage. binding keywords include “let”, “const” and “var”.

  3. What is an environment?
    A collection of bindings and their values existing at a given moment.

  4. What is a function?
    A program that is wrapped in a value. the values that are given in a function are called arguments.

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

  6. What is a side effect?
    Dialog box or writing text that pops up on a screen caused by a function.

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Console.log(Math.max(2,5));//->5 and Math.min(2,50+100);//->102

  8. What is control flow?
    the path of the execution of statements.

  9. What is conditional execution?
    Uses “if” keyword meaning a value is executed if certain conditions are met.

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

2 Likes
  1. A fragment of code that produces a value.

  2. Binding, or variable catches and holds values ​

  3. A collection of bindings and their values existing at a given time.

  4. Function is a piece of program wrapped in a value.

5.Prompt, log function.

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

  1. Prompt and log functions produces side effects and Math.max and min produces value.

  2. When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom. This is a straight-line control flow.

9.This is where a program can branch based on the situation at hand.

10 If keyword

2 Likes
  1. What is an expression?
    A fragment of code that produces a value is called an expression, i.e. 22 or "psychoanalysis.

  2. What is a binding?
    A “tentacle” that will grasp a value and attach it to something else. i.e. Let (blank) = (blank)

  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 piece of program wrapped in a value. Such values can be applied
    in order to run the wrapped program. i.e. “prompt”

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

  6. What is a side effect?
    When statement changes 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. Give an example of a function that produces a side effect and another function that produces a value.
    Side Effect - showing a dialog box or text on the screen. Example - console.log(Math.max(2, 4));
    // → 4
    Value - console.log(Math.min(2, 4) + 100);
    // → 102

  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?
    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”

2 Likes
  1. What is an expression?

A fragment of code that produces a value.

  1. What is a binding?

In Javascript a binding is there to catch and hold values. You can see them as tentacles which can grasp values.

  1. What is an environment?

The collection of bindings and their values that exist at a given time.

  1. What is a function?

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

  1. Give an example of a function.

prompt(“Enter passcode”);

  1. What is a side effect?

You can call it a side effect if a statement could display something on the screen that counts as changing the world, or it could change the internal state of the machine in a way that will affect the statements that come after it.

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

Showing a dialog box or writing text to the screen is a side effect.
The functions Math.max and Math.min for example will give you a value.

  1. What is control flow?

It’s the order in which the statements are executed. In Javascript from top to bottom unless of course in the code there is some instructions or statements that changes that control flow.

  1. What is conditional execution?

Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run. You have multiple different types of conditionals like If, Else and Else if.

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

If or else.

2 Likes
  1. What is an expression?
  • any valid set of literals, variables, operators that evaluates to a single value.
  1. What is a binding?
  • recording and storing something in a specific environment record
  1. What is an environment?
  • the collection of bindings and their values existing in a given instance
  1. What is a function?
  • a block of code designed to perform a particular task
  1. Give an example of a function.
  • function myfunction(p1, p2) { return p1 * p2;
  1. What is a side effect?
  • a code that returns a value which changes the world in any way. for example displaying something. These changes are called side effects.
  1. Give an example of a function that produces a side effect and another function that produces a value.
  • value= isNan
  • side effect= number()
  1. What is control flow?
  • direction and order of execution
  1. What is conditional execution?
  • execution of control flow if it meets certain conditions
  1. What kind of keyword do you need to use to invoke conditional execution?
  • if, else
2 Likes

1. What is an expression?

A piece of code that produces a value.

2. What is a binding?

A binding or variable is a container for data. This data can be a string, number, function or object.

3. What is an environment?

The collections of bindings or variables that exist in a program at any time.

4. What is a function?

A piece of stand-alone code that doesn’t execute unless the binding or variable in which that function is stored and called. The function can take one or multiple inputs as well.

5. Give an example of a function.

Some Javascript functions are console.log() and alert()

6. What is a side effect?

A side effect is some action that a function performs apart from returning a value. For example, the alert() function displays an alert box in the browser with the text given as input. This is the side effect of the function. It is possible for a function to do both; return a value AND have a side effect.

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

The alert() function is a function that produces a side effect.
If we define a function called multiply as follows:

function multiply(a, b) { return a*b; }

this is an example of a function that returns a value but performs no side effect.

8. What is control flow?

Control Flow is the sequence in which program statements are executed.

9. What is conditional execution?

It is the execution of a group of statements in a program based on if a certain boolean condition being true. Conditional execution is done with if/else statements.

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

The if / else keywords are used to enable conditional execution in a program.

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

  2. Bindings can be used to file pieces of data under a name, and they are useful for tracking state in your program.

  3. The environment is the set of bindings that are defined. JavaScript systems always put a number of useful standard bindings into your environment.

  4. Functions are special values that encapsulate a piece of program.

  5. You can invoke them by writing functionName(argument1, argument2)

  6. The modification of some kind of state, changing something somewhere.

  7. side effect - alert(“Hello World”);

value - console.log(Math.max(2, 4));
// → 4

  1. Is the order function calls, instructions, and statements are executed or evaluated when a program is running.

  2. Code gets executed, only if a certain condition holds.

  3. IF

2 Likes
  1. An expression is snippets of code that evaluates out to some new value but do not necessarily stand on their own. see gripe below

  2. A binding is what I’ve understood to be an “assignment” in other languages; i.e. the binding essentially names a value, or assigns a value to a name.

  3. An environment is the collection of bindings and their associated values that exist in the program; this depends on the physical and software context in which a program is running. e.g. the javascript environment within my web browser includes my keyboard/mouse/web browser bindings

  4. A function is essentially a program that has been named in order for one to execute it without having to write out the whole thing repeatedly.

  5. An example of a function is the console function we use so often to access its log section for outputting the results of evaluated expressions, e.g. “console.log ()” yields the output of whatever expression is used as its input (i.e. between the parentheses)

  6. A side effect is any noticeable affect an evaluated statement has on the environment, e.g.

  7. A side-effect producing function is for example the alert function because it pops up an alert with the inputted value as output; on the other hand an example of a function that produces only a value is math.max, which takes a list of numbers as input and finds the maximum value within it, but I GUESS this isn’t a side effect because the value isn’t stored anywhere (even though it may be output to the log or next/return line)???

  8. Control flow is basically the order in which statements are executed (or not) in a program.

  9. Conditional execution is essentially execution of a statement that depends on some condition being satisfied, e.g.if (x<y) {do whatever’s in here}

  10. Conditional execution is invoked using the “” keyword “if” followed by some conditions and maybe one or more “else” statements

gripe below
I copy this here because i have MAJOR problems understanding it (and i imagine i’m not alone), just fyi:
“The simplest kind of statement is an expression with a semicolon after it.
This is a program:
1;
!false;
It is a useless program, though. 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. It could display
something on the screen—that counts as changing the world—or it could change
the internal state of the machine in a way that will affect the statements that
come after it. These changes are called side effects. The statements in the
previous example just produce the values 1 and true and then immediately
throw them away. This leaves no impression on the world at all. When you
run this program, nothing observable happens.”

the problems i have here in order of importance:
the last sentence is contradicted completely by my use of the console when executing those statements. something observable happens, and as far as i can tell that observable thing is exactly what’s referenced in the 3rd sentence of the 2nd paragraph; it displays something on the screen.
knowing that it produces something observable, it is equally frustrating to interpret the preceding (i.e. next to last) 2 sentences that seem to contradict even themselves; the two “statements” (defined as such by the author) that are referred to apparently “leave no impression on the world at all”, and yet earlier we read that “A statement stands on its own…could display something on the screen --that counts as changing the world–”… so the “statements” aren’t statements?!

2 Likes
  1. What is an expression? A fragment of code that produces a value (any value written literally; an expression between parentheses; a binary operator applied to two expressions or a unary operator applied to one). Expressions can contain other expressions. An expression is analogous to a sentence fragment (as opposed to a statement in JS, which is analogous to a sentence).

  2. What is a binding? A statement that catches and holds values in the JS environment record. They should be thought of as tentacles rather than boxes as bindings can be disconnected from their current values and pointed to new values.

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

  4. What is a function? A piece of program wrapped in a value. A function can be invoked, called, or applied.

  5. Give an example of a function. console.log: outputs values to a text output device (e.g., the JS Console in web browsers). Note: values given to functions are called arguments.

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

  7. Give an example of a function that produces a side effect and another function that produces a value. It’s also showing a dialog box or writing text to the screen.

  8. What is control flow? The execution of statements from top to bottom (like a story).

  9. What is conditional execution? When a program takes the proper branch of a program based on the situation at hand. Created with the ‘if’ keyword in JS. The code is executed if and only if a certain condition holds. Example: show the square of the input only if hte input is actually a number.

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

2 Likes
  1. What is an expression?
    A Fragment of code that produces a value

  2. What is a binding?
    A thing that chatches and holds values in the JavaScript

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

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

  5. Give an example of a function.
    funcion CountEyes(EyeA , EyeB){return EyeA + EyeB}

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

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Side effect: console.log()
    Value: Math.max

  8. What is control flow?
    The order in wich a program is executet. It is always like a story and is read from top to bottom.

  9. What is conditional execution?
    Conditional execution descriebes two possible outcomes depending on the situation at hand. In JavaScript it is created with the “if” Keyword.

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

2 Likes
What is an expression?

an expression is any fragment of code that results in a value
What is a binding?
a binding is a value or string
What is an environment?
What is a function?
Give an example of a function.
What is a side effect?
Give an example of a function that produces a side effect and another function that produces a value.
What is control flow?
What is conditional execution?
What kind of keyword do you need to use to invoke conditional execution?

2 Likes
  1. A fragment of code that produces a value is called an expression.
  2. To catch and hold values, JS provides a thing called binding.
    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.
  3. Showing a dialog box or writing text to the screen is a side effect.
1 Like
  1. Expression a a fragment of a code that produces value.
  2. Binding is a thing used to catch and hold values. The keyword “let” indicates that the sentence will contain a binding.
  3. An environment is a collection of bindings and their values at any given time.
  4. A function is a piece of program wrapped in a value.
  5. prompt(“Enter name”)
  6. Side effect means writing a text or showing a dialog box to the screen.
  7. A function that produces side effect - prompt(“Enter value”) ;
    A function that produces value - console.log(Math.max(2,4));
  8. Control flow is the order in which a computer executes statements in a code.
  9. Conditional execution is creating a branching road where the program takes the proper branch based on the conditions.
  10. You need to use keyword “if”.
1 Like
  1. What is an expression?
    An expression is a fragment of code that produces a value.

  2. What is a binding?
    Bindings are like tentacles that let’s JS catch and hold values.

  3. What is an environment?
    An environment is a collection of bindings and values at a certain time.

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

  5. Give an example of a function.
    A prompt to enter a passcode within a web browser would be a function.

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

  7. Give an example of a function that produces a side effect and another function that produces a value.
    Produces side effect: prompt(“enter password”);
    Produces value: console.log(Math.max(2, 4));

  8. What is control flow?
    Control flow is the order of statements from top to bottom.

  9. What is conditional execution?
    Conditional execution let’s some code be executed if a certain condition holds, creating branching paths.

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

1 Like

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

Q.2.What is a binding?
A.2. JavaScript term for assigning values, by using the keywords (let, var, const).

Q.3.What is an environment?
A.3.A collection of bindings and their values that exist at a given time,
usually created at the time a program begins.

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

Q.5.Give an example of a function.
A.5. console.log(3 + 3);

Q.6.What is a side effect?
A.6 A statement that potentially changes the current status/state of the machine:
either (1) showing a dialog box, (2) displaying a result on the screen (3) changing the internal state of the machine in a way that will affect the next JavaScript statement(s) to be executed.

Q.7.Give an example of a function that produces a side effect and another function that produces a value.
A.7.side effect example: !true;
function example that produces a value: console.log(Math.abs(-33));

Q.8.What is control flow?
A.8. The program takes the branch(path) based on a test
of the condition(s) presented while executing JavaScript statements.

Q.9.What is conditional execution?
A.9. When JavaScript statements tests for a certain condition(s) and depending whether the values pass or fail, the program will then branch onto a specific path and then continue to execute the next JavaScript statements (on the respective chosen path).

Q.10.What kind of keyword do you need to use to invoke conditional execution?
A.10. By using the keywords ( if, else )

1 Like