- Results in a value
- A binding lets you bind a value to a name and store it in memory
- A collection of values and bindings that exists at any given time
- A piece of program wrapped in a value
- for(var i = 0; i<11; i++) {}
- Showing a dialog box or writing text to the screen
- alert(“I’m a side effect!”)
console.log(Math.max(2,4) + (Math.min(3,6))); - Statements are executed in order, from top to bottom
- if function, when a program has more branches it can take depending on the situation
- if, else
- Expression is any piece of code that produces a value
- Binding is like a tentacle that connects name to value
- Pre-existing bindings
- A piece of program with a name
- console.log(“hello”)
- Showing a dialog box or writing text to the screen
- prompt(“Enter password”)
Math.min(2, 5) - Order of executing statements (from top to bottom)
- It’s a way of changing the control flow depending on a logical condition
- if
- 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.To catch and hold values, JavaScript provides a thing called a
binding, or variable. - The collection of bindings and their values that exist at a given time is called
the environment. - A function is a piece of program wrapped in a value. Such values can be applied
in order to run the wrapped program. - Alert(“hello world”)
- Showing a dialog box or writing text to the screen is a side effect.
- alert(“hello”) vs. math.max(2,4)
- When your program contains more than one statement, the statements are
executed as if they are a story, from top to bottom. This is control flow - 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. - Conditional execution is created with the if keyword in JavaScript
[quote=“ivan, post:1, topic:3069”]
-
What is an expression?
A piece of code that produces a value is called an expression. -
What is a binding?
The newly produced value is stored under a name. It binds the result of an expression to a name. This name can then be used as an expression. -
What is an environment?
The collection of bindings and their values at a given moment. This includes the standard bindings of the programming language and the bindings created by the programmer. -
What is a function?
A function is a block of code designed to perform a specific task. In combination with a function value you can execute the function (call it)… -
Give an example of a function.
function add(first, second){
return first + second;
} -
What is a side effect?
A side effect is something noticeable happening when you run the code, or something changing in the statements that follow. -
Give an example of a function that produces a side effect and another function that produces a value.
function add(first, second){
alert( first + second);
}
add(3, 7)
function add(first, second){
return( first + second);
}
var sum = add(3, 7)
-
What is control flow?
The order in which the statements are executed. -
What is conditional execution?
The code is only executed if a certain condition is met, for instance an IF statement. -
What kind of keyword do you need to use to invoke conditional execution?
If/else, loop, boolean expression.
Continuing the discussion from Binding, Functions and Control Flow - Reading Assignment:
-
What is an expression?
A piece of code that produces a value -
What is a binding?
Aka a variable. A piece of code that holds a value. -
What is an environment?
The collection of bindings and their values that exist at a given time. -
What is a function?
A piece of program wrapped in a value. -
Give an example of a function.
prompt(“Enter passcode”); -
What is a side effect?
Showing a dialog 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.
prompt(“Enter passcode”);
console.log(Math.max(2, 5)); -
What is control flow?
The sequence in which your program executes statements, if there are more than one statements. -
What is conditional execution?
When a program takes a different path in different circumstances. -
What kind of keyword do you need to use to invoke conditional execution?
“If”.
What is an expression?
Expression is peace of code that represents value.
In this statement: var = 22
expression is value of 22.
What is a binding?
Connection to catch and hold the value.
var x = 10;
console.log(x * x);
What is an environment?
Collections of variabiles at a given time (browser powered background code).
What is a function?
Fundamental building block of code designed for particular task.
Give an example of a function.
function name() {}
alert(“Good morning!”); or
prompt(“subscibe”, “email”);
What is a side effect?
Function result that affect other statements down the code.
Give an example of a function that produces a side effect and another function that produces a value.
alert(“Good morning!”); side effect
var y = 10;
console.log(y * y); // 100 value
What is control flow?
Execution order of JS statements from top to bottom of the code
What is conditional execution?
Statement with an option between boolean routes (true or false).
if When true, execute. When false, go down do else if.
else if When true, execute. When false, go down do else if or else.
else When true, execute.
What kind of keyword do you need to use to invoke conditional execution?
for… else if… else…
- An expression is a fragment code that produces a value. Any value that is written literally is an expression.
- Binding is when a program stores values internally so that they can be used later.
- An environment is a collection of bindings and their values within a program.
- A function is a program wrapped in a value.
- Ex. The binding ‘prompt’ holds a function that makes a dialog box appear that asks for user input.
- A side effect is an observable change in the state of an application.
- Ex. alert(“this is a side effect”)
Ex. console.log(1+1); This produces a value. - It is the order in which individual statements, instructions or function calls in a program are executed.
- A statement created with the keywords ‘if’ or ‘else’ that controls the flow of execution of statements depending on the condition that is following the keywords ‘if’ or ''else.
- You need conditional expressions such as the keywords ‘if’’ or ‘else’.
What is an expression?
And piece of code that results in a value. An operator with 2vslues resulting in a 3rd value is an expression
What is a binding?
This is used to store a value for use in other expressions and statements
What is an environment?
This is the status of all binding that exist in the computer at any given moment.
What is a function?
A function is a set expression that can be invoked at anytime like a binder.
Give an example of a function.
The example in the book goes like this
prompt(“enter passcode”);
The binder ‘prompt’ invokes a function that will render a dialoge box on the computer prompting the user to enter a passcode.
Any expression can be stored within a function. In a simple way it is a shortcut so you do not have to replicate code to perform common operations within a program.
What is a side effect?
When the computer dies something as a result of a function or expression it is called a side effect. Showing a dialogue box with the prompt function is a side effect.
Give an example of a function that produces a side effect and another function that produces a value.
prompt(“enter passcode”);
will produce a dialogue box which is a side effect
let a = 2+2;
will produce the binding a=4
let a = (prompt(“enter passcode”));
This will open a dialgue box and ask the user to enter a value that will then be bound to the variable ‘a’
What is control flow?
This is the effect where by the computer will exectute expressions, and functions and statements in the order in which they are writtin in the program.
Thus there must be some logic to the order of operations and this is controlled by the order in which the expressions, and functions and statements appear in the program.
What is conditional execution?
This is where the control flow can be different when different conditions are present.
when a=1 then path 1 in the program is taken, if a=2 then path 2 is taken.
What kind of keyword do you need to use to invoke conditional execution? if
1. What is an expression?
A fragment of code that produces a value. 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. The simplest kind of statement is an expression with a semicolon after it.
2. What is a binding?
To catch and hold values, JavaScript provides a thing called a binding, or variable:
let caught = 5 * 5;
Commands ‘let’, ‘const’ and ‘var’ can be used to create a binding.
Binding names can be any word but the name must not start with a digit. A binding name may include dollar signs ($) or underscores (_) but no other punctuation or special characters. Special words which cannot be used for binding names, are:
break case catch class const continue debugger default delete do else enum export extends false finally for function if implements import interface in instance of let new package private protected public return static super switch this throw true try typeof var void while with yield
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. Values given to functions are called arguments.
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”);
6. What is a side effect?
An output of a function in a form of showing a dialog box or writing text to the screen
7. Give an example of a function that produces a side effect and another function that produces a value.
a) a function producing a side effect:
console.log(Math.max(2, 4));
b) a function producing a value:
function countApples(JansApples, Bensapples){
return JansApples + Bensapples
}
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.
Control flow refers to changes value types down the line so that the output of one function fits the required input type to the next function.
9. What is conditional execution?
Conditional execution is a branching road, where the program takes the proper branch based on the situation at hand. Conditional execution is created with the ‘if’ and ‘if/else’ keywords in JavaScript.
10. What kind of keyword do you need to use to invoke conditional execution?
while, if, if-else
-
What is an expression?
its a fragmented code that produces a value -
What is a binding?
its a way to catch and hold values. -
What is an environment?
the collection of bindings and their value at the given time. -
What is a function?
a piece of program wrapped in a value -
Give an example of a function.
a prompt shows a little dial box -
What is a side effect?
An expression that affects the statement that comes after it side effect. -
Give an example of a function that produces a side effect and another function that produces a value.
side effect: channel12 function: console.log(Math.max(2, 4)); -
What is control flow?
when statements are executed from top to bottom -
What is conditional execution?
when the program takes a branched road depending on the situation. not top to bottom. -
What kind of keyword do you need to use to invoke conditional execution?
we would use the if statement.
-
An expression is a fragment of code that produces a value, e.g. a value written, an expression between parentheses, a binary operator applied to two expressions etc. It’s like fragment of a sentence in human language.
-
A binding is when you tag a value to hold on to, e.g. tagging an expression to a new value, so when you call it out later it will give you that value.
-
A collection of bindings and their values at any given time.
-
A function is a program that is wrapped in value which is a collection of bindings to perform a task. When you ‘call’ a function, you usually directly use the name of the bindings that holds the function.
-
Example: console.log
-
A side effect is when a statement in the programming is changing the world (e.g. display something on the screen), or changes the internal state of the machine in the way that it will affect statements that come after it.
-
Function that produces a side effect - e.g. prompt (shows a dialog box asking user input);
Function that produces a value - e.g. Math.max (returns a value that is the greatest); Number (converts a value to a number). -
Control flow is the order how the program is executed when there is more than one statement. It goes from top to bottom just like how human reads a story.
-
Conditional execution - executing a program is like going down a path while meeting requirements of different conditions along it. Sometimes when the path branches out into more than one paths, it chooses its path depending on the deciding expression written after the keyword e.g. “if”, which sets out the conditions to execute.
-
if, else, else if, switch.
- A fragment of code that produces a value is called an expression.
- A binding or variable is used to catch and hold values.
- A collection of bindings and values that exist at a given time is called an environment.
- A function is a piece of program wrapped in a value.
- A binding prompt holding a function that shows a box asking for an input.
- Showing a dialog box or writing text to the screen is known as a side effect.
-
side effect function; console.log(Math.max(2, 4));
// → 4
value function; console.log(Math.min(2, 4) + 100);
// → 102 - The way that a program, containing more than one statement is executed.
- Conditional execution- creating a branch road, where the program takes picks the correct branch, based on the situation at hand
- keyword "if"
- A fragment of code that produces a value
- It holds a value that can be used later.
- A collection of bindings in a given time frame.
- A piece of program wrapped in a value thats pre-loaded in the default environment.
- console.log
- An Application state change that is observable outside the called function other than its return value.
- console.log text output is a side effect. Math.max calculates the largest number which is a value.
- The order in which statements are processed (top to bottom).
- When a program branches out and takes different paths based on ‘if’.
- ‘If’
- A code that represent some value, it can simple typed value or within the parenthesis with operators which return some value is called the expression.
- JavaScript defines the keywords or values which helps for defining the new values or storing values and having particular meaning called the binding.
- At the time of program starting all the Binding and their values available to use called the environment. The environment also provide the facility to interact with the surrounding system.
- A piece of program that wrapped into values called the function.
- prompt(“Enter passcode”) prompt function shows dialog box asking for the user input.
- Showing Dialog Box or writing sentence on the screen is called the side effect
- prompt(“Enter passcode”) prompt function shows dialog box means produces side effect and Math.max(2,4) function produces value
- Program contain more than one statement. The way of executing the statements one after the another is called the control flow
- During the execution of the program the part of program get executed according to the situation is called the conditional execution.
- if keyword used for conditional execution. The part of code executed when the particular condition is satisfied.
- What is an expression?
A fragment of code that produces a value
- What is a binding?
Binding stores value so you can use it later. Variables can catch and hold values, and therefore are also a binding.
- What is an environment?
A collection of variables and their values that exist at a given time is called environment.
- 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.
- Give an example of a function.
An alert function
- What is a side effect?
Showing a dialog box or writing text to the screen is a side effect.
- Give an example of a function that produces a side effect and another function that produces a value.
math.max function produces a side effect. console.log will produce a value
- What is control flow?
When your program contains more than one statement, the statements are executed from top to bottom.
- What is conditional execution?
When you can choose between two different routes based on a boolean value. It is written with an if statement.
- What kind of keyword do you need to use to invoke conditional execution?
if statement
-
The expression will returns a value
-
Binding is when you point a variable to another value
-
Environment is a collection of bindings and their values at the time of the programs existence.
-
A function is a group of code that can be called by the program to compute a value
-
Its a global function example… used to evaluate if a value is an illegal number
-
Side effect is a statement result that changes something that affects the program.
-
Control flow is the way the program is executed. Javascript control flow is top to bottom like humans read a page.
-
Conditional execution is like a fork in the road. The program uses if, else, if else to evaluate a condition and continue executing the branch of code based on the value returned from that condition.
-
if, else, else if
1, An expression is a piece of code that resolves to a value e.g var sum = a + b;
2, A binding or variable stores things that can called and used later.
3, An environment is the local variables.
4, Functions is something that accepts arguments then executes code then sometimes returns an output. It is used to abstract away commonly used tasks.
5, function sum(a,b) {
return a + b;
}
6, When an expression for function modifies something outside it’s own scope.
8, Control flow is the order of code execution.
9, Where conditions can be set to select different control flows.
10, Conditional execution can be invoked with if, if else, switch.
-
What is an expression?
An expression is any combination of values and operators that make another value. -
What is a binding?
A binding can hold the “memory” of an object, value or expression and define it for later use. -
What is an environment?
An environment is where expression(s) can be stored or resolved. -
What is a function?
A function reveals a value for a very specific purpose that can be called multiple times. -
Give an example of a function.
function HODL(BTC) {
if (BTC == “Satoshi”) {
return true;
} else if (BTC == “CIA”) {
return false;
}
}
-
What is a side effect?
Changes the state of the computer or the general output of the program creates some state change in the world thereafter -
Give an example of a function that produces a side effect and another function that produces a value.
A) alert(“hello world!”)
B) console.log() -
What is control flow?
Program containing more than one statement, they are then executed in one story, from top to bottom. -
What is conditional execution?
The branch path a program takes based on the situation and value returned from an expression -
What kind of keyword do you need to use to invoke conditional execution?
if
else
else if
- A fragment of code that produces a value is an expression.
- Binding catches and holds values.
- Environment is the collection of bindings and there value that exist at a given time.
- Function piece of program wrapped in values.
- Prompt (" Enter password");
- Side Effect showing a dialogue box or writing text to the screen.
- Side effect ex.
Prompt (" Enter your Password")
Value ex.
Console.log ( Math.max(2,4)); - Control flow order in which we code and have our statements evaluated.
- We may, for example, want to create a branching road, where the program takes the proper branch based on the situation at hand.
- If and else
-
What is an expression?
An expression can be multiple things:
A fragment from the code that creates the value.
A literal value.
An expression between parenthese.
A binary operator between 2 expressions.
An unary operator to 1 expression. -
What is a binding?
A binding a tool to grab en hold values. -
What is an environment?
An environment is a collection of bindings and their values at a certain time. -
What is a function?
A function is a piece of program wrapped in a value. -
Give an example of a function.
console.log and prompt -
What is a side effect?
A side effect is a result of a function. It is a value that is returned. However it is possible to have both a side effect and a value as a result. -
Give an example of a function that produces a side effect and another function that produces a value.
Prompt(“Give a number”)
Console.log(2+2) -
What is control flow?
Control flow is the way the code follows after each other. -
What is conditional execution?
Conditional execution happens when a branch is taken based on the given code. -
What kind of keyword do you need to use to invoke conditional execution?
If
Else