What is an expression?
An expression (or more expressions) are part of a statement each giving a result/value.
What is a binding?
A binding or variable, defined by a name, is a link to a value that is given to that binding at a certain time and can change if we assign another value to it inside a program. We can also have a constant wich points to a certain value and keeps that value a long as it lives
What is an environment?
An environment contains all the bindings/values that exist at a certain point in time
What is a function?
A function can have an input (argument), does something with it (the statements inside the function) and gives you back an output. The function is defined by a function name. After defining it we can call it by that name and give some argument(s).
Give an example of a function.
here is an example of a function to concatenate 2 arguments (or add them up if the args are numeric): function concatenate (arg1, arg2) {return arg1 + arg2}
What is a side effect?
A side effect is when a expression inside a function talks to the outside world (outside that function) for example changing a variable outside the function
Give an example of a function that produces a side effect and another function that produces a value.
without side effect:
function concatenate (arg1, arg2) {return String(arg1) + String(arg2)}
with side effect:
var arg1 = âHelloâ, arg2=âWorldâ;
function concatenate (arg1, arg2) {return String(arg1) + String(arg2)}
What is control flow?
the top to bottom execution of the statements that exist inside your program. It can be sequential (straight) or conditional
What is conditional execution?
Based on a condition that is true or false the program chooses a different path wich means different statements will be executed depending on the result of that condition.
What kind of keyword do you need to use to invoke conditional execution?
keywords are: If ⌠then ⌠else âŚ
What is an expression?
It is a pice of code that produces a value.
For instance:
1+2
âtrueâ+" love"
(1<2)&& (3==8)
What is a binding?
is a link between a space in the memory of the computer and a handler. The space in the memory holds a value and the handler is the name. For instance in
let cat= âcuteâ
the name is cat and the value is the string âcuteâ
What is an environment?
It is the collection of bindings and values in a program.
What is a function?
A function is a program that operates on a prescribed set of values
(its arguments)
Give an example of a function
Number()
Number.isNaN
Math.pow
What is a side effect?
Are the results (like the display of an output or a change
in the internal memory) produced by a statement and that
affect the code coming afterward.
Give an example of a function that produces a side effect and another function that produces a value.
An example that produces side effect:
prompt(âPick a numberâ)
An example that produces values :
Math.pow(2,2)
What is a control flow?
Is the order in which different statements appear in a program.
What is conditional execution?
Is a condition that has to be meet in order to execute a program.
What kind of keyword do you need to use to invoke conditional execution?
A conditional execution is implemented with the âifâ statement.
- A fragment of code that produces a value.
- Bindings are variables that can be named and stored.
- The collection of bindings and their values that exist at a given time
- A piece of program wrapped in a value
- prompt(âEnter passcodeâ);
- Showing a dialog box or writing text to the screen when executing a program code.
- Side effect: alert(âHello, world!â);
Value: counter++; - The âflow directionâ of executing a program, depending on conditional executions.
- Certain conditions to change the control flow if needed. (the program takes the proper branch based on the
situation at hand) - If, switch, for, whileâŚ
- An expression is a part of code, which creates a value.
- A binding (variable) is a value, which is stored in JS and can be named
- An environment is a scope of bindings, which exist at a given time.
- A function is a value with ability to perform an action
- An example of a function is prompt(âany valueâ). It shows a dialog box asking for input.
- A side effect is a changing which affects following statements, so can change the world in some way.
- !false; - produces only a value - true
alert(âsome valueâ); - produces a window - A control flow is a way of program execution.
- A conditional execution is a way of execution, which considers a condition of situation.
- if, else
- An
expression
is a piece of code that creates an output value. For example,!false;
-
Binding
is a way for JS to catch and store values, also known as variables. - An
environment
is the state of the bindings and values at a given time of the code. - A
function
is a piece of code represented in a value. - An example of a function in the binding
prompt
which has a function of asking users for input. - A
side effect
is an outcome of a function or statement that changes the state of another statement. -
// side effect prompt("Enter Number: "); // value console.log(Math.max(3,5));
-
Control flow
is the way your program behaves given its conditions and statements - Conditional execution is controlling the flow of your program based on prerequisites to be met.
- To invoke conditional executions, you must invoke keywords like
if
,else if
, andelse
.
âAn expression is a fragment of code that produces a value. Expressions are used as components of JavaScript statements.
âA binding, or variable, is an item that is used to store/point to a value. Commons words used to create bindings are LET, VAR, & CONST. CONST indicates that the identifier wonât be reassigned. LET is a signal that the variable may be reassigned and that it will only be used in the block it is defined. VAR is considered the weakest signal as it may or may not be reassigned & may or may not be used for an entire function.
âThe environment is a collection of bindings & their values that exist at a given time.
âA function is a piece of program wrapped in a value. These values can be applied in order to run the wrapped program. Executing a function is referred to as: invoking, calling, or applying the function.
âEx. function ivanIsPretty(handsome, stunning) {
return handsome + stunning;
}
â A side effect is a state change to an application that is observable outside the called function; other than the functions return value.
âSide Effect Function
alert(âCherry Blossomâ);
âValue Function
function addNumbers(1, 2) {
return 1 + 2;
}
âControl flow is the order in which a computer executes statements in a script.
âConditional execution is created with the word âifâ in order to execute code only under specific conditions. Conditional execution may be used when a programmer wants to create branches in the code.
-
What is an expression?
A fraction of code that produces a value. -
What is a binging?
a variable. This allows you to define something to be able to be used later. -
what is an environment?
collection of variables that compile to be called an environment. -
What is a function?
a type of structure to solve the problem you assign within it. -
Give an example of a function.
function addNumbers (myNumber, yourNumber) {
return (myNumber + yourNumber);
}
6.What is a side effect?
the outcome from a function (return).
7.Give an example of a function that produces a side effect and another function that produces a value.
side effect:
function subtractNumbers (a,b) {
return (a - b);
}
value:
console.log (4*6);
8.What is control flow?
the order that code is executed. top to bottom.
9.What is conditional execution?
when a conditional statement is provided that measures different outputs according to the information processed.
- What kind of keyword do you need to use to invoke conditional execution?
if and else.
-
What is an expression? A fragment of code that produces a value
-
What is a binding? It is used to catch and hold values. After a binding has been defined, its name can be used as an expression.
-
What is an environment? The collection of bindings and their values that exist at a given time.
-
What is a function? A piece of a program wrapped in a value. Function calls can be used within larger expressions.
-
Give an example of a function. prompt(âEnter Passwordâ);
-
What is a side effect? An expressing that changes the internal state of the machine in a way the it will affect the statements that come after it. Showing dialog box or writting text to a screen is a side effect.
-
Give an example of a function that produces a side effect and another function that produces a value. Side Effect function prompt(âEnter passcodeâ); Value function console.log(Math.max(2, 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? Used to create 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â keyword
- A fragment of code that produces a value
- Also called a variable, that which holds values
- The collection of bindings and variables that exist at a given time.
- A reusable fragment of programmatic logic which accepts one or more values and returns a value.
- const square = function(x) {
return x * x;
}; - Altering state that exists outside of the function.
- // Side effect:
var x = 1;
function (x) {
x = 2;
}
// returns a value
function (x, y) {
return x + y;
} - Path of execution that a program takes.
- Optional paths or control flows based on program state.
- if, else, while for, break, switch-case-default
1.) What is an expression?
Answer: A fragment of code that produces a value.
2.) What is a binding?
Answer: Is the way that JavaScript defines value referenced as a variable. These values can be changed at any time.
3.) What is an environment?
Answer: The collection of bindings and their values that exist at a given time.
4.) What is a function?
Answer: A piece of a program that is wrapped in a value.
5.) Give an example of a function.
Answer: prompt(âEnter Emailâ);
6.) What is a side effect?
Answer: The subsequent changes that take place to other commands from an expression after it is entered to the computer.
7.) Give an example of a function that produces a side effect and another function that produces a value.
Answer: alert(âClick OKâ); - Brings up a dialog box
console.log(1 + 1); - Produces the value of 2
8.) What is control flow?
Answer: The order in which the code or statements are written to be executed.
9.) What is conditional execution?
Answer: Created with the âifâ keyword, it is the conditional way a program executes based on the conditions at hand.
10.) What kind of keyword do you need to use to invoke conditional execution?
Answer: Keyword "if"
What is an expression? Code which includes literals, variables, operators, and expressions that produces a single value.
What is a binding? A binding or a variable is assignment of internal state used to catch and hold values.
What is an environment? An environment is the collection of bindings that exist at a given time that have been made within a program.
What is a function? A function is a block of a code wrapped in a value. Code that performs a specific task and usually returns a value.
Give an example of a function. var x = myFunction(4, 3);
What is a side effect? Is any application state change that is observable outside the called function other than its return value.
Give an example of a function that produces a side effect and another function that produces a value: Prompt or log are examples of functions which result in side effect. A pure function produces no side effects, which means that it canât alter any external state. A. Example of side effects Making a HTTP request, Mutating data, Printing to a screen or console, DOM Query/Manipulation.B. Pure function produces no side effects, and produces a value such as Var sum = 9+1.
What is control flow? you can use to incorporate a great deal of interactivity in your application.
What is conditional execution? Conditional execution means that some part of the code is going to be executed only if certain condition
What kind of keyword do you need to use to invoke conditional execution? if, else, else if
Binding, Functions and Control Flow - Reading Assignment
1. What is an expression?
An expression is any piece of code that returns a value. You can have expressions within expressions.
2. What is binding?
Binding is another name for variable. You can use the = operator to assign a value or expression to a binding (or variable).
3. What is an environment?
The collection of bindings and their values at any given time is called the environment.
4. What is a function?
A function is a named section of code that performs a certain task. After defining a function, you can call it as many times as you want. Functions can have functions within the function. Functions can also return a value. Some functions don't return anything. Some functions have no parameters and others have 1 or more that are required for the function to execute.
5. Give an example of a function.
console.log("Hello World")
The console.log function outputs information to the console. In this example, Hello World will be displayed on the console.
6. What is a side effect?
In the previous example, the function doesn't return anything because it has a side effect - printing to console.
7. Give an example of a function that produces a side effect and another function that produces a value.
See question 5 for an example of a function with a side effect.
Other functions, like Math.max, take any amount of parameters, and returns the highest number.
Math.max(2,100,50) would return 100.
8. What is control flow?
Control flow is the order in which individual statements, instructions, or function calls are executed or evaluated.
9. What is conditional execution?
A statement that controls the flow of execution depending on some condition.
10. What kind of keyword do you need to use to invoke conditional execution?
- if
- else
- elseif
- switch
-
What is an expression?
Piece of code that results in a value -
What is a binding?
Tying a value or string to a variable -
What is an environment?
All of the bindings in existence -
What is a function?
A reusable block of code that can be executed as needed. -
Give an example of a function.
function doubly(num) {
return num*2;
} -
What is a side effect?
Showing a dialog box, writing text to the screen or a change to the internal state of the machine in a way that 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.
function doublyWithSideEffect(num) {
alert(âSide effectâ);
return num*2;
}function doubly (num) {
return num*2;
} -
What is control flow?
the direction/flow of instructions within a program. -
What is conditional execution?
Using conditional logic to control what parts of a program execute -
What kind of keyword do you need to use to invoke conditional execution?
if, else, else if, switch
1. What is an expression?
It is a fragment of code that produces a value. Expressions can contain expressions as well and as analogy with human languages, an expression is a fragment of a sentence which is the statement and a program is a list of statements.
2. What is a binding?
It is how JavaScript holds values, the keywords used for that purpose are let, const or var. The difference between let, const and var is about the life cycle of the value : let and const let the value visible per block of code, however var lets the value visible for all code long.
3. What is an environment?
It is the collection of bindings and their values that exist at a given time.
4. What is a function?
It is a piece of program which returns a value or performs a task.
5. Give an example of a function?
Math.max(5, 7);
6. What is a side effect?
It is mainly a semantic error where a statement could change 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.
⢠Side effect : alert (âThis is greatâ);
⢠Value : Math.min(7, 8);
8. What is control flow?
It is the order in which the statements are executed, from top to bottom.
9. What is conditional execution?
It is done when a condition appears with the keyword if and the program execution can take the same or another set of statements depending on the condition.
10. What kind of keyword do you need to use to invoke conditional execution?
The principal keyword is if followed by else or else if.
- A fragment of code that produces a value is called an expression.
- Binding is a way for a computer the remember something with a value.
- 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
- console.log(âThis is a print functionâ)
- side effect is a functionâs behavior other than returning values.
- alert(); - side effect, math.max(1,2); - value
- Control flow is the programs execution order, in our case, itâs top to bottom.
- Conditional execution is a statement that binds the control flow to a condition for the different path it should take.
- âifâ and if need âelseâ.
1. What is an expression?
Is any fragment of code that produces a value.
2. What is a binding?
Is a pointer to a value in memory.
3. What is an environment?
Is a collection of bindings that hold some values that are create when the system execute. This bindings allow access information or interact with the surrounding system.
4. What is a function?
Is a piece of code wrapped with brackets. When it is invoke, every row of that code is executed, then maybe some value is return. A function can be just declared or hold in some binding.
5. Give an example of a function.
var smartContract = function(value) {
var amount = 100;
return amount + value;
}
6. What is a side effect?
Is the any other result of a function than not be the return of a value.
7. Give an example of a function that produces a side effect and another function that produces a value.
Function that produce a side effect:
console.error('The program is wrong.');
Function that produce a value:
Math.max(1, 3, 8);
8. What is control flow?
The program normal flow is to run every code row, one after other, from top to bottom. There are some statements that allow change the normal flow, therefore control flow of program.
9. What is conditional execution?
When there are two or more branching road in a program, and the proper branch is take based on some situation that is verify by conditional statement.
10. What kind of keyword do you need to use to invoke conditional execution?
The follows keyword: âifâ, âelseâ, âelse ifâ, âswitchâ, âcaseâ, âdefaultâ.
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 theenvironment.
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. Such values can be applied in order to run the wrapped program. For example, in a browser environment, the binding prompt holds a function that shows a little dialog box asking for user input.
Give an example of a function.
prompt(âEnter passcodeâ);
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.
Side effect - console.log(Math.max(2, 4)); // â 4
Value - console.log(Math.min(2, 4) + 100); // â 10
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?
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.
What kind of keyword do you need to use to invoke conditional execution?
If or else
What is an expression?
What is a binding?
A binding is an expression that is tied to a defined value. It analogous to a tentacle in that its job is to grab something.
What is an environment?
The environment is the term used when referring to the values ascribed to each binding at any given time.
What is a function?
A function is a piece of program wrapped in a value.
Give an example of a function.
The dialogue box is an example of a function. It can be invoked by typing âprompt(âenter passcodeâ);â
What is a side effect?
Didnât really understand.
Give an example of a function that produces a side effect and another function that produces a value.
The dialogue box is a side effect of a function, and the Math.max function will produce a value (the greatest number).
What is control flow?
Control flow refers to the fact that a bunch of statements will be executed from top to bottom.
What is conditional execution?
Conditional execution is when the program only executes x if a certain condition is met, such as if a number is higher than 9, then x. If not higher than 9, then y.
What kind of keyword do you need to use to invoke conditional execution?
If
1:fragment of code that produces a value
2 use of var to reference to other variable
3.collection of variables and their values that exist at a given time
4. Piece of program wrapped in a value , values can be applied in order to run program
5. alert (âxxxâ) , console.log ("___")
6.some functions produce a side effect could be a text box
7. side effect = alert , mathmax or mathmin gives a number
8. the order of execution of commands
9. conditional execution which gives a optional path by using IF command
10: IF
- An expression is a fragment of code that produces a value
- A binding is a thing that catches and holds values
- A collection of bindings and values that exist at a time
- A function is a piece of program wrapped in a value
- Prompt(âsomethingâ);
- A side effect is a showing a dialog box or writing text to the screen
- The function that produces a value is Math.max that takes any amount of numbers and gives back the greatest Ex: console.log(Math.max(2, 4)); it gives 4
- Control flow executes a program that contains more than one statement as a story, from top to bottom.
- Conditional execution is a branching road where the program takes the branch based on the situation
- If is the keyword used to invoke conditional execution