- a fragment of code that produces a value
- a collection of variables and their values as they exist at a given time
- a piece of program wrapped in a value. The value can be “applied” in order to run teh wrapped program.
- somethign produced by a function, such as a dialog box or writing text on a screen
- when a program contains more than one statement, those statemetn are executed from top to bottom in “stragiht line order”
- this is a break from stratight line order, where a program choses between two paths of execution based on a boolean value
- “if”
-
What is an expression?
In javascript, any small section of program that produces a “value”. -
What is a binding?
Same as Variable; we “bind” (Hence Binding ) a name of our choice (variable name) with a certain section of computer memory, and we assign a value to that chunk of memory; so that the computer remembers that value for us to use when we need it. -
What is an environment?
The ready state of a program at startup is called the environment, which contains all bindings including what we create, language specific and system bindings. -
What is a function?
A chunk of code that runs a specific procedure based on a given value.
Give an example of a function.
let testVar1 = 10
let testVar2 = 20
function exampleName (testVar1, testVar2){
return (testVar1 % testVar2)
}
console.log (exampleName (testVar1, testVar2)); -
What is a side effect?
Prompt or alert dialog boxes are examples of a functions side effect, and the real effect is the result we get back inside those dialog boxes. -
Give an example of a function that produces a side effect and another function that produces a value.
Prompt (“Enter Your Name”), prompt is a function with a side effect
Math.max (10, 20), Math.max is a function with NO side effects -
What is control flow?
Sequential and logical execution of smaller chunks of statements and expressions inside a large program. -
What is conditional execution?
Basically the logical structure or the algorithms that build an entire program. -
What kind of keyword do you need to use to invoke conditional execution?
The “if” keyword invokes a condition.
What is an expression?
An expression is any valid set of literals, variables, operators and expressions that evaluates to a single value. The value maybe a number a string or a logical value.
What is a binding?
A binding is the way a program stores a value to be used later.
What is an environment?
An environment is the collection of bindings and their values that exist at a given time.
What is a function?
A function is a block of code designed to perform a task. A function Is executed when something invokes it.
Give an example of a function
function myFunction(p1, p2) {
return p1 * p2; // The function returns the product of p1 and p2
}
What is a side effect?
A Side effect is what a function produces.
Give an example of a function that produces a side effect and another function that produces a value.
An example of a side effect of a function is a dialog box alert(“This is a side effect”); . A value of what a function produces is an expression that returns a value ie . console.log(math.max(2, 4)); // -> 4.
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.
What is conditional execution
When we create a branching road, where the program takes the proper branch on the situation at hand.
What kind of keyword do you need to use to invoke conditional execution?
“if” and “else” are the kind of key words used to invoke a Conditional Execution.
What is an expression?
Any combination of literals and variables.
What is a binding?
Basically similar to a pointer in other languages. It’s a label for a variable. Internally it’s likely a memory address that points to the location where a value is stored (but haven’t looked at the internals).
What is an environment?
This seems to be similar to the machine state in my RAD Studio IDE when a program is running in the debugger. The values of the variables are all live in JS console.
What is a function?
A function is similar to a procedure except that it returns a value. It’s a label that can be used to call a set of statements to do work. It can include one or more parameters.
Give an example of a function.
Number() in JS returns a boolean as to whether or not the parameter contains a number.
What is a side effect?
When procedures, functions or statements modify anything outside of its own scope, it is producing side effects.
Give an example of a function that produces a side effect and another function that produces a value.
side effect: prompt(“enter userid”);
value: let UserID = “enter userid”;
What is control flow?
This is the order of execution of statements in a program which can be modified by conditionals and loops that cause branches and re-execution.
What is conditional execution?
It’s a spot in the code that evaluates an expression to determine whether the code to be executed is executed next or not. Typically used is the if…then, or case/switch statements to evaluate conditionals
What kind of keyword do you need to use to invoke conditional execution?
if (condition) {
}
1. What is an expression?
A fragment of code that produces a value. An expression corresponds to a sentence fragment in the English language.
2. What is a binding?
It is a statement that is used to catch and hold a value. It consists of a keyword followed by a name of the binding and, if you want to give it a value, followed by an “=” operator and an expression.
3. What is an environment?
It is the collection of bindings and their values that exist at a given time in a program.
4. What is a function?
A type of value with a piece of program wrapped in the value.
Example: You call a function by putting parenthesis after an expression that produces a function value, e.g; prompt();
5. Give an example of a function.
const square = function(x) {
return x * x;
};
console.log(square(12));
6. What is a side effect?
Any application state change that is observable outside the called function. Some common side effect functions on JavaScript include alert, prompt, and console.log.
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
const makeNoise = function() { console.log("Pling!"); }; makeNoise();
Function produces a value
const power = function(base, exponent) {
let result = 1;
for (let count = 0; count < exponent; count++) {
result *= base;
}
return result;
};
console.log(power(2, 10));
8. What is control flow?
When the program has two or more statements, statements are run as a controlled flow, top to bottom of that control flow. The running order of statements is called control flow. The order function calls, instructions and statements are executed when a program is executing.
9. What is conditional execution?
Allows the program to take a different direction under a specific circumstance, or when a condition is met using conditional or selection statements (if, else if, else).
10. What kind of keyword do you need to use to invoke conditional execution?
if, else if, else
What is an expression?A fragment of code that produces a value
What is a binding? a way to capture new information but must be used soon after attaching new value otherwise it gets lost. it is also called a variable.
What is an environment?The collection of bindings and their values that exist at a given time is called
the 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: let (the record show I know shite);
What is a side effect?A side effect is a function which produces an expression and returns that value.
Give an example of a function that produces a side effect and another function that produces a value.console.log(Math.min(2, 4) + 100);
// → 102
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.
What is conditional execution?a branching road, where the program takes the proper branch based on the
situation at hand.
What kind of keyword do you need to use to invoke conditional execution?if, and, switch, else
-
An expression is a fragment of code that can be used to compute value.
-
A binding is a variable used to catch and store values.
-
Environment is the collection of bindings and their values that exist at a given time
-
A Function is a is a block of code designed to perform a particular task.
-
Examples of a function: Prompt function, console.log function, alert function
-
Showing a values, dialog box or writing text to the screen is a side effect.
-
Function that produces side effect:
alert( Hello Word)
//Hello word (on the screen)Function that produces a value: Math.min(2, 4); // 2
-
Control Flow is a Structures in JS that allow program with many statements to be executed as if they are a story, from top to bottom.
-
Conditional execution is where program are executed based on different conditions not a straight road.
-
Conditional Execution Keywords: if, else, else if, switch.
What is an expression?
A fragment of code that produces a value is an expression. Syntax must be correct.
What is a binding?
The keywords let, var, and const attach a value to a binding, so that whenever the binding is invoked, the computation to achieve that value is performed.
What is an environment?
What’s typed into the console, essentially all the bindings and their values at any given time.
What is a function?
A function is an already known expression that has it’s own expression associated with it. It’s basically a commonly used “sentence” already pre-programmed so you can just invoke the function and move on instead of writing it out again.
Give an example of a function.
console.log is an example, alert, prompt is a function that displays a form field for user to input information
What is a side effect?
Different from environment, side effects usually occur on the front end of a website. It literally produces an effect to the end-user, like a form field or alert message.
Give an example of a function that produces a side effect and another function that produces a value.
(alert) function produces a side effect and (math.max) takes any amount of number arguments and returns the greatest valued one.
What is control flow?
Control flow is controlling the values of expressions in coding, by branching segments of code depending if certain conditions meet.
What is conditional execution?
The if keyword executes or skips a statement depending on the value of a boolean expression.
What kind of keyword do you need to use to invoke conditional execution?
the if keyword, and subsequent else keywords.
What is an expression? A fragment of code that produces a value is called an expression.
What is a binding? To catch and hold values, JavaScript provides a thing called a binding, or variable:
What is an environment? The collection of bindings and their values that exist at a given time is called the 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. A JavaScript function is a block of code designed to perform a particular task.
Give an example of a function. function myFunction(p1, p2) {
return p1 * p2; // The function returns the product of p1 and p2
}
JavaScript Function Syntax
A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses ().
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. Side effects include: Modifying any external variable or object property (e.g., a global variable, or a variable in the parent function scope chain)
Give an example of a function that produces a side effect and another function that produces a value. alert(“alert is a function that produces a side effect”) console.log(2+4); produces a value.
- prompt(“Enter passcode”); has the side effect of a prompting dialogue box.
- console.log(Math.max(2, 4)); produces no side effect, though produces a value.
What is control flow? The control flow is the order in which the computer executes statements in a script. When your program contains more than one statement, the statements are executed as if they are a story, from top to bottom. This example program has two statements. The first one asks the user for a number, and the second, which is executed after the first, shows the square of that number. let theNumber = Number(prompt(“Pick a number”));
console.log("Your number is the square root of " +
theNumber * theNumber);
What is conditional execution? The if/else statement is a part of JavaScript’s “Conditional” Statements, which are used to perform different actions based on different conditions. In JavaScript we have the following conditional statements: Use if to specify a block of code to be executed, if a specified condition is true.
What kind of keyword do you need to use to invoke conditional execution? if and else.
**What is an expression?
A piece of code that has a value (e.g. a=5, b=4, “hello world”). It is more like a fragment sentence, if compared to human language.
*** What is a binding?**
it allows to hold or catch values. let (keyword) caught =12/6. Caught is a binding.
*** What is an environment?**
It refers to the collection of bindings and their values at a given time.
*** What is a function?**
A piece of program wrapped in a value.
*** Give an example of a function.**
alert (“wake up,buddy!”); –alert is a function that triggers a dialog box with a text
*** What is a side effect?**
It is a change that is caused by modification or alteration of some statements (e.g. their variables) which will affect the statements that come after it.
*** Give an example of a function that produces a side effect and another function that produces a value.**
Side Effect: E.g. Suppose z(1,2) = 9. If z(1,2) can be replaced with 9 and no any distribution of the program is observed, then z(1,2) has NO side effects. However, if the behavior of the program changes after replacing, then there is a side effect.
Value: w=“Mango”. we just gave w the “Mango” value.
*** What is control flow?**
execution of statements from top to botton. -------->
*** What is conditional execution?**
when there are more than 1 option for direction/execution of the statement, and this choice is based on the situation.
*** What kind of keyword do you need to use to invoke conditional execution?**
if
1. What is an expression?
Any fragment of code that produces a result can be called an expression.
2. What is a binding?
Bindings or variables are things provided by the language to catch and hold values.
3. What is an environment?
The collection of bindings and their values that exists at a given time are 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.
prompt("Enter your Nickname");
6. What is a side effect?
A side effect is a tangible action that the function produces like writing text to the screen.
7. Give an example of a function that produces a side effect and another function that produces a value.
An example of a side effect could be a dialog box instance produced by a function. On the other hand a function that produces a value could be a mathematical function retrieving a numeric value.
8. What is control flow?
Control flow is the way programs execute their statements. It could be straight-line, chose different paths validating different conditions or repeating statements using loops.
9. What is a conditional execution?
A conditional execution is determined when a program can take a proper branch based on the situation at hand.
10. What kind of keyword do you need to use to invoke a conditional execution?
Conditional execution is created with the word if
in JavaScript.
- An expression is a fragment of code that produces a value.
- A binding is essentially computer memory, a binding is like a tentacle in which it grasps a certain piece of info. we use binding to often save something we will be using later.
- an Environment is a group/collection of bindings and their values.
- a Function is a piece of program wrapped in a value.
- Prompt(“Enter Passcode”);
- A side effect is a change that occurs in another part, rather than the actual function containing the code.
- function addTen(Value){
return value+10;
} - 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.” - if and else are two keywords needed to invoke a conditional execution.
What is an expression?
Expression is fragment of code that produces a value.
What is a binding?
Binding is a thing with which we can catch and hold values.
What is an environment?
Environment is the collection of bindings and their values that exist at a given time.
What is a function?
A function is a piece of program wrapped in a value.
Give an example of a function.
function example(a, b) {
return a + b;
}
What is a side effect?
Side effect is 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.
Function that produces a side effect: alert(“hello world”)
Function that produces a value: console.log(Math.max(5, 15))
What is control flow?
Control flow is the order in which statements are executed.
What is conditional execution?
Conditional execution means that the program executes certain lines of code only if certain conditions are met.
What kind of keyword do you need to use to invoke conditional execution?
We need to use “if”.
1. What is an expression?
An expression is “any fragment of code that creates a value.” Therefore, can take a number of different forms, some of which may not be immediately apparent to those new to JavaScript. This includes:
a. Any value written literally. (“apple”, 4, true) are all expressions in and of themselves.
b. Any expression between parentheses is itself an expression.
c. Any Binary or Unary operator applied to it’s respective number of inputs is an expression.
Another thing to note is that an expression can contain another separate, distinct expression nested within the larger expression. This nested expression can too contain yet ANOTHER expression nested within it, and so on.
The JS idea of nested expressions discussed above is similar to the idea in the English language of a sentence fragment nested within another larger sentence fragment. Both sentence fragments are themselves sentence fragments, but the larger fragment can take rely on the smaller fragment as one of its components.
If an expression is only analogous to a sentence fragments, then what would be the JS equivalent to a full self standing sentence found in English? The answer: a "Statement" . Statements can stand on their on in JS, and are the building blocks of a program. A program is simply a list of statements. The simplest statement is an expression with a semicolon after it; put 2 of these together and you have the simplest type of program. If it’s just a simple expression followed by a semicolon, then this program will be a useless one because it will essentially do nothing but create a value only to immediately throw it away afterwards. However, the program’s lack of utility does NOT disqualify it from being a valid program, technically speaking. See the useless example program below example below:
“2;
!true;”
If the program is not ‘useless’–that is to say it’s execution outputs values that are in fact durable (ie, survive through time and are not immediately erased after execution such as when a variable is named that can be later used to refer to it’s underlying value)–the lasting changes the program created are known as “side effects.”
2. What is a binding?
A Binding is process by which the JavaScript engine ‘remembers’ values and assigns them to a variable for later use. The structure of a binding is as follows:
let freemasonry = 11*3;
console.log(freemasonry);
// --> 33
‘let’ is a keyword that directs the JavaScript engine to treat the proceeding text in the statement as a ‘binding’. This means that JS will expect what follows “let” to take the form:
- binding name
- OPTIONAL ‘=’ operator and it’s associated value – you do NOT have to declare what the newly created variable’s value at the moment it is created. Instead, you can assign that later.
Key - After a variable is bound to a value, it is NOT permanent. You can reassign the value associated with a bound variable by using the ‘=’ operator and changing what follows to something different. Example below:
let mood = “light”;
console.log(mood);
// → light
mood = “dark”;
console.log(mood);
// → dark
*Can define
*Calling the value of a variable with an empty binding returns "undefined"
*Beyond let, other keywords exist to bind variables to values. Bindings using “var” and “const” are syntactically identical to let, with the only difference being that either of the new keywords would be substituted for let
Var, which stands for variable, will be touched on later and has complicated properties.
Const, which stands for constant, defines a constant binding which will point the variable to the same value for as long as it lives.
3. What is an environment?
An environment in JavaScript is the collection of bindings and their associated values that exist at any given time. This is never empty, even on startup, because of the bindings that are baked into the language standard along with ways to interact with the surrounding system (like to read keyboard inputs on a particular loaded website).
4. What is a function?
A function is “a piece of program wrapped in a value.” You can call/invoke a function by putting parentheses after an expression that produces a function value–which is generally the name of the binding that holds the function–and filling between those parentheses with the necessary value(s)–which are known as “arguments”.
5. Give an example of a function.
prompt(“Enter passcode”);
^this function call will produce a popup window named “Enter Passcode” that will prompt the user to input text into the dialogue box.
6. What is a side effect?
“Side effects” are the lasting changes a program creates, which in regards to functions can be popup dialogue boxes, writing text to the screen, etc. Functions are not constrained to ONLY producing side effects, they can also produce a value. But as discussed previously in the early part to this answer and the response to question 1, side effects are distinguished by creating lasting changes to the environment that are NOT immediately thrown away. When a function creates a value, that is not a lasting change because that output is not able to be retrieved after it is created. There must be a side effect of the function that causes the returned value to be saved, such as binding it to a variable.
7. Give an example of a function that produces a side effect and another function that produces a value.
a) Side effect producing function:
prompt(“Enter passcode”);
b) Value producing function:
console.log(Math.max(2, 4));
_ // → 4_
8. What is control flow?
Control flow is the process by which a programer seeks to control the order of execution of the different lines of code.
9. What is conditional execution?
Conditional execution is a tool in control flow where a programer can set a conditional statement (also known as an ‘if statement’) to direct the flow of execution. If the condition is met, then a distinct new event will take place. However, if the condition set in the ‘if statement’ is NOT met, then flow will move in a different direction. This is accomplished using boolean statements and testing for whether 1 of the 2 conditions (true or false) exists in the specific instance where it is called in the program, and setting the program to take a certain action or series of actions contingent on the value of the initial boolean statement. The book gave the following example:
let theNumber = Number(prompt(“Pick a number”));
if (!Number.isNaN(theNumber)) {
console.log("Your number is the square root of " + theNumber * theNumber);
} else {
console.log(“Hey. Why didn’t you give me a number?”);
}
10. What kind of keyword do you need to use to invoke conditional execution
The ‘if’ keyword is needed to invoke conditional executions
What is an expression? a fragment of code that expresses a value.
What is a binding? A statement that catches and holds a value. A binding is made up of a keyword and a name for the binding.
What is an environment? A set of bindings and their values in a given program at a given time.
What is a function? A program wrapped in a value.
Give an example of a function. prompt(“Enter Name”);
What is a side effect? A side effect is when calling a function causes the program to take some tangible action.
Give an example of a function that produces a side effect and another function that produces a value. The alert(); function creates the side effect of a popup box displaying the string entered between the parenthesis. The Math.max(); function produces a value that is the largest number in a set between the parenthesis.
What is control flow? Control Flow is the order in which your program executes multiple statements in a program. By default Programs execute a linear Control Flow from top to bottom.
What is conditional execution? Conditional Execution is where the program performs one of a set choice of functions based on set conditions within the program. This allows for a program to return different values for instance based on what conditions within the program are met.
What kind of keyword do you need to use to invoke conditional execution? Using the if/else functions can invoke conditional execution.
1- A fragment of code that produces a value
2- A binding is a way for the program to keep and store an internal state.
3- An environment is a collection of bindings and values that exist at a given time in a program.
4- A function is a piece of program wrapped in a value.
5- An example of a function is Console.log(), it will print to the console whatever is between the parenthesis (it will perform operations if included within it.
6- A side effect is writing text to the screen or showing a dialog box
7- Prompt() produces a side effect as it will show a dialog box on the screen for the user to input data on. Math.max() produces no side effect, as all it does is take the largest number of a series of values given to it.
8- Control flow is the order in which our expressions will be executed within the program.
9- Conditional execution is when we want to execute certain lines of code only if a certain condition is given.
10- In order to invoke conditional execution, we use then if and else keywords.
- An expression is a piece of code in a statement. For example, it can be a value or a combination of values and operators: 4+5
- A binding keeps the connection to a value and stores it for usage in later statements. The keywords to introduce a binding can be let, const or var. The connection from a binding to a value can be changed to other values.
- An environment is the values and bindings existing at a time.
- A function is a value, which can wrap up several statements. The values which are given into the function are called arguements.
- function add (let a, let b) {return a+b;}
- A side effect is a functions influence to the world, for example a function which shows a text on a screen.
- prompt(“Hello World”); function add (let a, let b) {return a+b;}
- Control flow means, that the statements in a program are executed from top to bottom.
9.Conditional execution happens, by using conditions like if, while, do in a program. Conditions can interupt the straight flow of statements in the program. - if
-
An expression is a fragment of code that produces a value
-
a variable, stored so it can be retrieved later
-
Environment is a collection of variable at their current value
-
A function is a list of commands to execute around certain variables
-
Example console.log(Math.max(2, 4));
-
A side effect is a value which is linked to an external source. ie. a prompt box or writing a message on screen
7.prompt(“would you like chocolate?”) - side effect
var a = 1
var b = 2
console.log(a*b) -
control flow is the options that data has to produce an output and the sequence.
-
conditional execution, uses operators to determine if a function can execute is if or while, or case statements.
-
keyword if to create a conditional execution.
- An expression is a fragment of code that produces a value.
- Bindings catch and hold onto values in a program.
- The environment is the collection of bindings and their values, at a given point in time.
- A function is a piece of program wrapped in a value. This value can be applied in order to run the program wrapped in it.
- console.log is an example of a function
- Side effects are changes which affect the change the world, i.e. produces some meaningful output, or changes the internal state of a machine such that the following statements are affected.
- Showing a dialog box or writing text to the screen is an example of a function that produces a side effect.
Math.max is a function that returns a value, and these functions are considered expressions as well. - Control flow dictates the order of execution of a program; like a story, from top to bottom.
- Conditional execution is where the program execution is based on the conditions defined when a certain situation is met.
- Conditional execution is invoked by the if keyword
-
What is an expression?
It is a fragment of code that, when run, produces a value. Expressions can be nested, meaning there can be expressions within expressions. -
What is a binding?
It’s a characteristic that variables have of grasping on to values, to have access or affect them in some way. -
What is an environment?
It’s a set or collection of variables and their values existing at any given time – the current status of their relationship. -
What is a function?
A function is a piece of program wrapped in a value. When a value is “applied” to a function, the wrapped program executes using the value(s) as variable(s). -
Give an example of a function.
var codingTeacher = “Ivan”;
console.log ("My coding teacher’s name is: ", codingTeacher ); -
What is a side effect?
A side effect is the change that results from a statement. To be meaningful, a side effect needs to leave an impression on the world. This can be done by, for example, binding it to a variable. -
Give an example of a function that produces a side effect and another function that produces a value.
// Producing a side effect…
console.log(“hello world”)
// Producing a value…
var multiplyThis = 2 * 2;
console.log("The answer is: ", multiplyThis); -
What is control flow?
Control flow is the order in which a program executes. Usually from top to bottom. -
What is conditional execution?
As a program executes, some statements re-route or alter the execution flow. Sometimes based on a Boolean value or other loop-creating keyword. -
What kind of keyword do you need to use to invoke conditional execution?
To invoke conditional execution, usually Boolean IF / ELSE statements are used. But there are more, such as FOR, WHILE / DO.