-
What is an expression?
A fragment of code that produces a value is call an expression. Every value that is written literally is an expression. -
What is a binding?
To catch and hold values, JavaScript provides a thing called a binding or variable. The key word “let” indicates that this sentence is going to be a binding. -
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 lot of the values provided in the dfault environment have the type “function”. A function is 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 is a side effect. -
Give an example of a function that produces a side effect and another function that produces a value.
side effect: prompt (“Enter passcode”);
function: console.log (Math.min (2,4) + 100); -
What is control flow?
When a program contains more than one statement, the statements are executed as if they are a story, from top to bottom. -
What is conditional execution?
If we want 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
- What is an expression?
A fragment of code that produces a value. Every value that is written literally is an expression.
- What is a binding?
It holds a value. An example of this is a let statement.
- What is an environment?
The collection of bindings and their values 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.
Entering a passcode in order to gain access to a webpage.
- 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.
- 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 is a side effect. Whena function produces a value, it is said to return that 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 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
A fragment of code that produces a value is called an expression.
To catch and hold values, JavaScript provides a thing called a binding, or variable: let caught = 5 * 5;
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. For example, in a browser environment,
the binding prompt holds a function to display a dialog box asking for user input. Showing a dialog box or writing text to the screen is a side effect.
Functions may also produce values, in which case they don’t need to have a side effect to be useful. For example, the function Math.max takes any amount of number arguments and gives back the greatest.
console.log(Math.max(3, 5));
// →5
The control flow is the order in which the computer executes statements in a script. A Conditional Execution is when we create a branching road, where instead of going directly down one road from start to finish, the program takes a branch based on the situation at hand. Conditional execution is created with the if keyword in JavaScript.
- Piece of code that produces a value.
- Binding stores a value to be used later.
- Environment is a set/collection of bindings and values that exist at any time.
- Expression wrapped in a value.
- console.log prompt alert
- A function that modifies the state of something outside its own scope.
- Side effect: console.log(abcdefg);
Value: let abcdefg = 11; - The order in which the instructions of the program will follow and execute.
- Where a program will execute different branches/statements depending on the situation at hand.
- if, else, if else
- Returns a value
- When you point/reference a variable to a value
- Environment is the the collection of bindings and their values at that point in time of the programs existence.
- Expression wrapped in a value. It can be executed by calling it.
- isNan() is a global function example… used to evaluate if a value is an illegal number
- An observable change in the state of the application
- 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. - The order of executing code from top to bottom left to right.
- Determines wether or not to execute certain parts of the code.
- if, else, else if
-
What is an expression? Any unit of code that can be evaluated to a value is an expression.
-
What is a binding? Giving a variable (imagine a container) a value. ie. var myShoeSize = 9;.
-
What is an environment? The environment is when/where all the bindings and their values exist at that moment.
-
What is a function? A function is a block of code that can have values sent to it, on which it performs the pre-coded purpose, and then returns a value or performs a task.
-
Give an example of a function.
function floorAreaInMetres(m1, m2) {
return m1 * m2; // The function returns the multiplication (*) of m1 and m2
} -
What is a side effect? It is when a function prints to the screen, or produces a dialogue box.
-
Give an example of a function that produces a side effect and another function that produces a value.
FUNCTION WITH SIDE EFFECT:
function floorAreaInMetres(m1, m2) {
alert(m1 * m2); // The function alerts the user the multiplication (*) of m1 and m2
}
FUNCTION THAT PRODUCES A VALUE:
function floorAreaInMetres(m1, m2) {
return m1 * m2; // The function returns the multiplication (*) of m1 and m2
}
-
What is control flow? Control flow is the direction that the computer executes the code. ie. from top to bottom.
-
What is conditional execution? Where the code to be executed relies on the outcome of a question or condition. ie.
if (trumpIQ>130) {
alert(“Really?!”); // block of code to be executed if the condition is true
} else {
alert(“Knew it.”); // block of code to be executed if the condition is false
}
Although ‘else’ is not necessary in order for it to still be a conditional execution. It can just use the ‘if’ statement. -
What kind of keyword do you need to use to invoke conditional execution? The IF keyword.
-
What is an expression?
it is a piece of code that creates a value -
What is a binding?
it’s a placeholder for a value, like a number or an object or a string -
What is an environment?
it is the collection of values that exist at a given time where the program is running -
What is a function?
short pieces of code that are a part of the main program and are wrapped around a value -
Give an example of a function.
function add(x,y){
return x + y;
} -
What is a side effect?
it is a action performed by a function like opening a new window or showing some text on the screen -
Give an example of a function that produces a side effect and another function that produces a value.
function addtwo(x,y){
return x+y;
}
returns the value of x + yfunction show(){
alert(“have a good day”);
}
opens a window that says good day -
What is control flow?
it’s a representation of the way programs are executed and this can take many shapes depending on the type of program and its complexity -
What is conditional execution?
it’s the kind of control flow that an “if” statement introduces into a program, basically it branches the way a program is executed to different instructions depending on certain conditions -
What kind of keyword do you need to use to invoke conditional execution?
the keyword “if”
- What is an expression?
Expression in JavaScript is a fragment of code that produces a value.
- What is a binding?
Bindings are used to catch and hold values. They do not contain values intrinsically, they grasp them and hold until they are affected by running of the program and consequentially assigned or attached to a new value.
- What is an environment?
An environment is the collection of bindings and their values that exist at a given time in JavaScript program. Some bindings in JavaScript have assigned default values that are part of default environment.
- What is a function?
In JavaScript, a function is a set of statements that performs a task or calculates a value.
- Give an example of a function.
function exampleFunction(a,b){
a = Number(prompt("Input first number"));
b = Number(prompt("Input second number"));
sum=a+b;
alert("Sum of your two numbers is " + sum);
};
This function is invoked by typing: exampleFunction(); Little pop up dialog box will ask user to “Input first number” and “Input second number” via two prompt functions tied to bindings “a” and “b”, which are predefined to hold number values. After assigning this two numbers to “a” and “b” binding “sum” will take value of sum of those two inputted numbers. At the end, pop up dialog box invoked by alert function will be shown saying "Sum of your two numbers is X“where X is the sum value of inputted numbers.
- What is a side effect?
Side effect is when a statement or function result in displaying something on the screen (like dialog box or writing text) or it changes 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.
alert(“This is the example of a function that produces a side effect”);
Math.min(5,9);
<!--Math.min is the example of function that produces value. It takes any amount of number arguments and gives back the smallest.-->
- What is control flow?
When program contains more than one statement, the statements are executed from top to bottom. This order of execution is called control flow and If we don’t use conditionals or loops we get straight-line control flow.
- What is conditional execution?
Conditional execution is when we use conditions for execution of our statements and thus creating branching of paths in our program.
- What kind of keyword do you need to use to invoke conditional execution?
Conditional execution is created with the “if” keyword in JavaScript. You can use the “else” keyword, together with “if”, to create two separate, alternative execution paths or you can even chain multiple paths to choose from (more than two) by introducing “else if” keywords.
- A fragment of code that produces a value is called expression.
- In order to store or hold value temporarily, a variable is used and it is called binding
- The collection of bindings and variables that exist at a given time is called binding.
- A function is a piece of program wrapped in a value.
- function examplefunction (p1,p2) {
return p1*p2 ;
} - Showing a dialog box or writing text to the screen is called dialog box.
- Example of function with side effect
function plusWithSideEffects(x, y) {
alert(“This is a side effect”);
return x + y;
}
Example of function with value
function examplefunction (p1,p2) {
return p1*p2 ;
} - Control Flow Structures allow your code to take certain actions based on a variety of scenarios
- Conditional execution means executing a code only when some condition is met.
- If and If Else
-
What is an expression?
An expression is a fragment of code that produces a value. -
What is a binding?
Binding is a thing in javascript that catch and holds values. -
What is an environment?
It is a colection of bindings and values existing at a given time. -
What is a function?
Is a piece of program in a value. -
Give an example of a function.
prompt(“Enter passcode”); -
What is a side effect?
Are changes that can display something on the screen-changes the world, or changes 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.
prompt(“Enter passcode”);
console.log(Math.max(2, 4));
// → 4
-
What is control flow?
Is the way statements are executed. -
What is conditional execution?
Is a code that executes if a certain condition holds. -
What kind of keyword do you need to use to invoke conditional execution?
if
- What is an expression?
An expression is a piece of code containing values and operators that results in a new output or value.
- What is a binding?
A binding is like a file location that is set up within the console; it’s a name linked to a value which the programmer can call on to use in writing code. This value, while often having its own value, could also be the result of a pre-existing expression involving other values. Bindings include ‘var’, ‘let’ or ‘const’ at the beginning of the code line. Binding names have to start with a letter, although can contain numbers, and can’t have spaces or any pre-established keywords.
- What is an environment?
The environment is like the main folder on a console which contains all the file names (bindings) at a given time.
- What is a function?
A f unction is a pre-existing binding name within the browser environment that when ‘applied’ produces a certain result.
- Give an example of a function.
prompt is a function which produces a text box within the browser with the further option to click OK or cancel.
- What is a side effect?
A side effect is the production of a function that doesn’t result in a value directly but instead produces a physical layer to the program, such as a text box or text displayed to the screen.
- Give an example of a function that produces a side effect and another function that produces a value.
An example of a function that produces a side effect is a text box. Examples of a function that produce a value in an expression are ‘is greater than’ ( < / > ) or ‘choose the lower value of the two’ ( Math.min (( data)).
- What is control flow?
Control flow is using a combination of statements placed together to produce a chronological order to the statements – ie from top to bottom or left to right.
- What is conditional execution?
A conditional execution is an expression that places conditions within the statements in order to arrive at a value. These different conditions could be one or a variety of different routes to get to that resulting value.
- What kind of keyword do you need to use to invoke conditional execution?
The keywords ‘if’ and ‘else’ invoke conditional execution.
1, A fragment of code that produces a value.
2, A process by which JS captures and holds values.
3, A collection of bindings and their values that exist at a given time.
4, A piece of programme wrapped in a value(fragment of code).
5, prompt(“enter passcode”);
6, A statement that could change the internal state of the machine in a way that affects statements that come after it or showing a dialogue box or writing text to the screen.
7, math.max
console.log(math.min(2,4)+100);
// -> 102
console.log(math.max(2,4));
->4
8, when a programme contains more than one statement , the statements are executed from top to bottom.
9, Creating a branching road where the programme takes the correct/proper branch based on the situation at hand.
10, If.
What is an expression?
A fragment of code that produces a value is called an expression.
What is a binding?
JavaScript provides bindings to catch and hold values
What is an environment?
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.
In a browser environment the binding prompt holds a function that shows a little dialog box asking for user input.
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.
Side effect: prompt("Enter your name: ");
value example: console.log(Math.max(2, 4));
What is control flow?
If 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?
If we want 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?
For example IF
1 What is an expression?
It is a fragment of code that produces a value.
2 What is a binding?
A binding is a memory that catches and holds values.
3 What is an environment?
An environment is 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.
prompt(“Enter passcode”);
6 What is a side effect?
A side effect is a statement that changes the world, (display something on screen) or 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.
console.log(Math.max(2, 4));
// 4
console.log(Math.min(2, 4) + 100);
// 102
8 What is control flow?
Is the order that statements are executed, ( Top to Bottom).
9 What is conditional execution?
A conditional execution is an execution that can go one way or another.
10 What kind of keyword do you need to use to invoke conditional execution?
if
-
a fragment of code that produces a value
-
to catch and hold values
-
the collection of binding and their values that exist at a given time
-
a piece pf program wrapped in a value
-
a function that holds a little dialog asking for user input
-
showing a dialog box or writing text to the screen
-
let num = 0;
const func = () => {
num = 1;
return true;
}
func(); -
when your program contains more than one statement, the statement are executed as if they are a story, from top to bottom.
-
where a program takes the proper branch based on the situation at hand.
-
If
my god, how far are we going without doing an actual practical exercise. all those single line examples are not going to stick without a bigger real exercise making something a little bit more complex with all these things.
Have patience, my friend.
You must learn to crawl before you can learn to walk.
-
a piece of code that outputs a value is called an expression.
-
a binding is the way you connect a name to a value. so we can later use the name for further inputs.
-
an environment are the bindings and their values that are already there when you open a program like a web browser. for things like reading the keyboard and using the mouse.
-
a functions is a piece of default program that is wrapped in a value.
-
the prompt binding opens up a dialog box.
-
when the outcome affects the real world, like showing something on the screen
-
side effect: prompt(“this is the only example they show in the book”)
value: console.log(Math.mil(5, 2)); -
the way your program is executed is from top to bottom like a book.
-
You can work with an “if” function, so you’re program can go 2 or more directions.
-
“if” and “else”
-
What is an expression?
Any kind of value or code that produces a value could be an expression. -
What is a binding?
They catch and hold values. There also can be a constant binding which gives the defined value as long as it exists. -
What is an environment?
It´s the collection of values and bindings that exist for a given time. -
What is a function?
A piece of program wrapped in a value. -
Give an example of a function.
return -
What is a side effect?
A function that produces a side effect like showing a dialog box or writing text on the screen. -
Give an example of a function that produces a side effect and another function that produces a value.
console.log
Math.min -
What is control flow?
How statements are executed. -
What is conditional execution?
If you have different possibilities for the work flow and the program takes the proper one. -
What kind of keyword do you need to use to invoke conditional execution?
the if word
haha i made a calculator