-
an expression is a fragment of code that produces a value.
-
binding is used by javascript to catch and hold values in memory for later use.
-
an environment is a collection of bindings and their values at a given time.
-
a function is a piece of program wrapped in a value. Thus when called it acts on an input to give an output.
-
prompt(),
console.log(), -
side effects are the results of statement that affects the world or change the internal state of the machine in way that will effect the statements that come after it.
-
an example of a function that produces a side effect is the function prompt()
an example of a function that produces a value is the function console.log() -
control flow is the linear execution order to a number of statement from top to bottom.
-
conditional execution is when a program executes statements in an order based on the situation at that point.
-
we use the keyword if() to invoke conditional execution.
-
What is an expression? it can be only a value or values combined with operators
-
What is a binding? itâs a variable which can be associated with values
-
What is an environment? itâs the combination of variables and values which are in the program
-
What is a function? itâs a program which is set inside a variable
-
Give an example of a function.
i define a program which make division
i set this program in the function called DIVISION
once i set the arguments in the function it will give me the result -
What is a side effect?
when a function shows something on the screen -
Give an example of a function that produces a side effect and another function that produces a value.
prompt(âokâ)
console.log(2+3) -
What is control flow?
it represents how the instructions are executed -
What is conditional execution?
it is when a condition is set in the rules, so there can be 2 or more different output basing on the conditions -
What kind of keyword do you need to use to invoke conditional execution?
IF and ELSE
1 : A part of code that produces a value, like a fragment of a sentence
2: a tag to a value. for example : let apples = 10; so we created a binding called apples, and we assigned the value 10 to it. If we then type apples = 5; the tag move from the 10, to the 5. but the code changes only when we assign another variable.
3: The collection of bindings and their values that exist at a given time. (basically, the âoperating systemâ basic language to be able to work and understand your commands in Javascript)
4:piece of program wrapped in a value
5: alert(âWAKE UPâ);
6: a line printed on the screen. A result of an expression
7: VALUE console.log(Math.max(10,66)); // â 66
SIDE EFFECT printZeroPaddedWithLabel
8: execution of statements in order, from top to bottom. Like nonces in TXs, first TX to be sent out from your wallet is going to be the one with the lowest nonce first and increasing by 1 then
9: the equivalent of the word IF in our language. A Code is going to be used only if a condition applies.
10: if,else
-
A fragment of code that produces a value is called an expression.
-
Biding is the way a program keeps its internal state and remembers things.
-
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.
-
alert(textToShow);
-
Showing a dialog box or writing text to the screen is a side effect.
-
side effect: alert(TextToShow);
value: console.log(Math.min(3, 8) +100); will output value 103 -
When your program contains more than one statement, the statements are
executed as if they are a story, from top to bottom. -
Conditional execution means that a code is executed if and only if a condition is fulfilled.
-
Conditional execution is created with the if keyword in JavaScript.
- An expression is a value which is written
- A binding stores the values from variables.
3.An environment are the values of variables currently in the memory - A function is a small calculation made seperately which you can call later on in your program.
- A function example: function name() { insert code here } call your function : name();
- A side effect is for example when you call a dialog box to the screen.
- An example of a func that causes a side effect is
function(){ {
var name = prompt("What is your name?);
alert("hello " + name);
}
-
A control flow is the order of the code.
-
A conditional execution is when the code choose to act differently from the input of the user.
-
A keyword to execute a conditional execution is âifâ
- An expression is a piece of code which produces a value.
- A binding or a variable is used to store value.
- A collection of bindings and their values that exist at a given time.
- A function is a piece of program wrapped in a value.
- alert(âHello, World!â)
- Showing a dialog box or texts to the screen.
- side effect > alert(âHello, Worldâ)
value > Number.isNaN(cat) - The order in which the program executes or skips.
- The flow of the program can choose paths based on conditions provided.
- IfâŚelseâŚ
-
What is an expression?
An expression produces a value and can be written wherever a value is expected, the value may be a number, a string, or a logical value. -
What is a binding?
Binding is used by JavaScript to catch and hold values -
What is an environment?
Is the collection of bindings and their value at a given time. -
What is a function?
A function allow programmers to divide a program into a several numbers of functions to facilitate communication with different environments, browser, computer âŚetc. -
Give an example of a function.
function Greetings() {
alert (âHello there!â);
}
We call the function :
Greetings(); -
What is a side effect?
The side effect is when a statement for example change the state of the machine in a way that will affect the statements that will come after if. -
Give an example of a function that produces a side effect and another function that produces a value.
Function that produces value :
}
-Side effect
function Greetings() {
alert (âHello there!â);
}
-
What is control flow?
Control flow is when a program contain many statements, these one are executed in order from the top to the bottom. -
What is conditional execution?
A conditional execution is to execute a code using the if , only in a certain condition the code execute -
What kind of keyword do you need to use to invoke conditional execution?
if, else, else if, switch
What is an expression?
An expression is a sequence of one or more operands and zero or more operators that can be evaluated as a single value, object, method, or namespace.
What is a link? it is an expression that connects certain information with another. The link can be an image, a word, a hypertext, a web address, a programming line, a direct reference ⌠that redirects you to other related information.
What is an environment? is a program or set of programs that encompasses all the tasks necessary for the development of a program or application. These tasks are basically the following: Editing the program. Compilation and linking. Execution. Depuration. Others also include the creation of complementary documentation that facilitates the maintenance of the program within these functions.
This type of environment incorporates numerous tools, utilities, already developed applications, examples, tutorials, etc. All of them aimed at facilitating and improving development.
What is a function? A function is nothing more than a set of lines of code that do a specific task, and this function can return a value, OR not; Functions have the possibility of having parameters or arguments, which are variables that modify their behavior.
Thanks to the functions we can segment the code into different parts, making it easier.
Give an example of a function.
function hello () {
| | alert (âhelloâ);
{ Hello ();
Here we see an example of a function in JavaScript; Our function is called hello.
And what it does is show a word on the screen, hello. And to call it from anywhere in our code, just put hello and parentheses. In this way. In this case this function returns nothing and has no parameters either.
What is a side effect?
It simply refers to modifying some type of state, for example: Changing the value of a variable. Writing some data to disk Enabling or disabling a button in the user interface Itâs really simple.
Side effect = change something somewhere
Give an example of a function that produces a side effect and another function that produces a value.
Console. Log produces functions, Math.max produces a value
What is the control flow?
Flow control refers to the order in which the instructions that we have in the program are executed. The order can be ascending, descending or we can execute a set of instructions some determined number of times where some values ââare modified and until the value meets any condition, those instructions are no longer executed.
Determining the order of the instructions depends primarily on the algorithm that we want to develop in the program.
What is conditional execution?
There are two ways to alter the flow depending on a condition. The basic idea is to find ourselves at a fork in a path, in which we will follow one or the other path depending on the answer to a question that is written on the fork.
A variant of this is that instead of two possibilities, we are presented with more ways to follow.
What type of keyword do you need to use to invoke conditional execution?
The most elementary form of conditional flow control is the
if-else statement, the syntax of which is as follows:
if (conditional_expression)
statement1
else
statement2
- An expression is a piece of code that produces a value. Expressions can contain other expressions.
- A binding is a value that is associated with a name which can be invoked later. The name can be used as an expression.
- An environment is a collection of bindings and their values that exist at a given time.
- A function is a A function is a piece of program wrapped in a value
- prompt, alert,
- A side effect is result of an statement that significantly change the internal state of the machine in a way that will affect the statements that come after it.
- prompt(âyou agree?â)
console.log(âyesâ+â I agreeâ) - Direction of statements execution from top to bottom.
- Conditional execution is when we want that some code to be executed if, a certain condition holds.
- Conditional execution is created with the
if
keyword in JavaScript.
- A fragment of code that produces a value.
- Binding is the way program keeps an internal state and memorising things.
- 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.
- In a browser environment, the binding prompt holds a function that shows a little dialog box asking for
user input. - Showing a dialog box or writing text to the screen is a side effect.
- Side effect -
prompt(âEnter passcodeâ);
Value -
console.log(Math.max(2, 4));
// â 4 - When your program contains more than one statement, the statements are
executed as if they are a story, from top to bottom. - 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. In the simple case, we want some code to be executed if, and only if, a certain condition holds. - If and else
-
What is an expression?
A fragment (semantically as well) of code that produces a value; every value that is written literally. -
What is a binding?
a way of keeping an internal hold on a value for later use or reference. -
What is an environment?
a collection of bindings and their values that exist at a given time. like your Browser and prompt. -
What is a function?
a piece of program wrapped in a value, a subprogram. -
Give an example of a function.
prompt(âEnter passcodeâ); -
What is a side effect?
a program that affects the statements that come AFTER it. -
Give an example of a function that produces a side effect and another function that produces a value.
let one = 1, two = 2;
console.log(one + two);
// â 3 -
What is control flow?
The order of statements executed in a program: from top to bottom. -
What is conditional execution?
when a program takes a proper road/branch or option based on the situation. âifâ proposition: a code to be executed if, and only if, a certain condition is meet. -
What kind of keyword do you need to use to invoke conditional execution? âifâ keyword.
- An expression is a fragment of code that produces a value.
- A Binding is a fragment of code, defined by a keyword, that points to & catches a value.
- An Environment is a collection of bindings & their values that exist at a given time.
- A Function is a piece of code that is wrapped in a value. These values can be applied to run the wrapped program.
- let name = prompt(enter your name please);
- A Side Effect is what is produced or written to the screen when a function runs.
- Alert " " produces a side effect
console.log (1+2+3); produces a value - Control FLow describes the way multiple statements are executed one after the other as the code parses from top to bottom.
- Conditional execution describes the branching of the program flow according to conditions that are met or otherwise as the program advances through its statements.
- The keyword IF is used to evoke conditional execution.
What is an expression?
-
A fragment of code that produces a value is called an expression.
-
Values with applied operators to make them create new values (this whole process is called an expression) is the main substance of any JavaScript program.
-
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.
-
Expressions can contain other expressions in a way similar to how subsentences in human languages are nested.
-
The simplest kind of statement is an expression with a semicolon after it.
-
An expression can be content to just produce a value, which can then be used by the enclosing code.
What is a binding?
-
To catch and hold values, JavaScript provides a thing called a binding, or variable.
-
The special word (keyword) âletâ indicates that this sentence is going to define a binding.
-
It is followed by the name of the binding and, if we want to immediately give it a value, by an = operator and an expression.
-
After a binding has been defined, itâs name can be used as an expression. The value of such expression is the value the binding currently holds.
-
When a binding points at a value, that doesnât mean itâs tied to that value forever.
-
The = operator can be used at any time on existing bindings to disconnect them from their current value and have them point to a new one.
-
Two bindings can refer to the same value.
-
When you define a binding without giving it a value, the tentacle has nothing to grasp, so it ends in thin air.
-
If you ask for the value of an empty binding, youâll get the value undefined.
-
A single let statement may define multiple bindings.
-
The words var and const can also be used to create bindings, in a way similar to let.
-
Binding names can be any word.
-
Digits can be part of binding names âcatch22â is a valid name â but the name must not start with a digit.
-
A binding name can include ($) sign or (_) but no other punctuation or special characters.
KEYWORDS THAT CANâT BE USED AS BINDING WORDS:
- â break, case, catch, class, const, continue, debugger, default, delete, do, else, enum, export, extends, false, finally, for, function, if, implements, import, interface, in, instanceof, let, new, package, private, protected, public, return, static, super, switch, this, throw, true, try, typeof, var, void, while, with, yield.
What is a constant?
-
The word âconstâ stands for constant.
-
It defines a constant binding, which points at the same value for as long as it lives.
-
This is useful for bindings that give a name to a value so that you can easily refer to it later.
What is an environment?
-
The collection of bindings and their values that exist at a given time is called the environment.
-
When a program starts up, this environment is not empty.
-
It always contains bindings that are part of the language standard, most of the time, also has bindings that provide ways to interact with the surrounding system.
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.
-
E.g. the binding âpromptâ holds a function that shows a little dialog box asking for user input.
-
Executing a function is called invoking, calling, or applying it.
-
You can call a function by putting parentheses after an expression that produces a function value.
-
A function is a block of code designed to perform a particular task.
-
A function is executed when âsomethingâ invokes it (calls it).
-
A function is defined with the âfunctionâ keyword, followed by a name, followed by parentheses ().
-
The code to be executed, by the function, is placed inside curly brackets: {}.
-
Function parameters are listed inside the ().
-
Function arguments are the values received when it is invoked.
-
Inside the function, the arguments (the parameters) behave as local variables.
FUNCTION INVOCATION
The code inside the function will execute when âsomethingâ invokes (calls) the function:
-
When an even occurs (when a user clicks a button).
-
When it is invoked (called) from JavaScript code.
-
Automatically (self invoked).
FUNCTION RETURN
-
When JavaScript reaches a âreturnâ statement, the function will stop executing.
-
If the function was called from a statement, it will âreturnâ to execute the code after the invoking statement.
-
Functions often compute a return value. The return value is âreturnedâ back to the âcallerâ.
WHY FUNCTIONS?
-
You can reuse code: Define the code once, and use it many times.
-
You can use the same code many times with different arguments, to produce different results.
THE () OPERATOR INVOKES THE FUNCTION
- Accessing a function with () will return the function object instead of the function result.
FUNCTIONS USED AS VARIABLE VALUES
- Functions can be used the same way as you use variables, in all types of formulas, assignments, and calculations.
LOCAL VARIABLES
-
Variable declared within a JavaScript function, become LOCAL to the function.
-
Local variables can only be accessed from within the function.
-
Since local variables are only recognized inside their functions, variables with the same name can be used in different functions.
-
Local variables are created when a function starts, and deleted when the function is completed.
What are arguments?
- Values given to functions are called arguments.
Give an example of a function.
- âpromptâ is an example of a built in 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.
-
âalertâ function produces a side-effect which shows an alert box to client.
-
âconsole.logâ produces a value to the JavaScript console.
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, want to create a branching road, where the program takes the proper branch based on the situation at hand (conditional execution).
-
Itâs created with the âifâ keyword in JavaScript.
-
We might want some code to be executed if, and only if, a certain condition holds.
-
The deciding expression is written after the keyword âifâ, between parentheses, followed by the statement to execute.
What kind of keyword do you need to use to invoke conditional execution?
- You use âifâ and âelse" keywords to invoke a conditional execution.
- What is an expression?
- A fragment of code that produces value. It can be a number, a string, a true or false value. As long as it brings something, it is an expression. Usually expressions are combined in statements to make something useful.
- What is a binding?
- If you want to save a value for later expressions, you bind it to a variable, aka binding. It doesnât really hold a value in itself, it rather attaches to it, makes a tie. Several bindings can attach to the same value.
- What is an environment?
- Bindings that exist at a given time. There are always some bindings. E.g., on a browser there are bindings that take mouse and keyboard input and interact with the present webpage.
- What is a function?
- A list of statements combined for some purpose.
- Give an example of a function.
- let number;
if (number % 2 == 0) {
console.log(âevenâ);
} else {
console.log(âoddâ);
}
With this function we could find out if a variable called number is an even or odd number at this point. Zero would also appear as even because we havenât defined an exception for it.
- What is a side effect?
- When statement causes a change in the world, e.g. something appears on the screen.
- When statement causes a change in how computer operates, thus affecting statements that come after it.
As I see it, in a mathematical sense, a function should only produce value, so the things above are called side effects. In programming it is confusing because the so-called side effects are usually the thing we want. Of course, sometimes we may also need the produced value and only the value.
- Give an example of a function that produces a side effect and another function that produces a value.
- console.log () doesnât produce anything, it makes things appear on the console.
- Number () takes a string value and produces number value from it.
- What is control flow?
- An order of execution of statements. Generally, statements are executed top to bottom unless we define otherwise, and this is straight line control flow.
- What is conditional execution?
- It happens when we split the control flow to take different paths if different conditions are met.
- What kind of keyword do you need to use to invoke conditional execution?
- We do this by using if keyword. We can make several of these splits with else if. If we want to define default action if none of conditions are met, we use else.
Generally, it looks like this:
if (condition 1) {
action 1;
} else if (condition 2) {
action 2;
} else {
default action;
}
- An expression is a part of code that posses a value.
- A binding is a variable as it catches/hold a value.
- An enviornment is a collection of bindings and their values.
- A function is a piece of program where values can be applied to run it.
- A prompt dialog box is an example of a function.
- A side effect is an effect other than the return value of a function and is produced by some functions, such as writing text to screen.
- Dialog box produces a side effect and Math.max produces a value.
- Control flow is top to bottom flow of your code statements. Programâs story.
- A condition execution is where program can take an alternative path depending on circumstances.
- Keyword if is needed to invoke conditional execution.
Answers:
-
A fragment of code that produces a value is know as an expression.
-
Binding also is known as variable is how a program remembers things in its internal state.
-
The collection of binding and their values that exist at a given time is called the Enviroment.
-
A function is a piece of program wrapped in a value. It was a set of statements (values) that performs a task.
-
An example of function is math.max which task to choose the higher number in a string.
-
A side effect is a change to the internal state of the machine in a way that will affect the statements that come after it.
-
The command âalertâ produces a side effect and a function like max / min returns a value.
-
Control flow is when a program contains more than one statement then the program will execute within a controlled flow for example like top to bottom.
-
Conditional execution is created with the if keywords follow by adding braces {} to the statements after the word if. It means it will execute a different path base on a situation or if a certain condition is met.
-
The keyword âifâ can use to invoke conditional execution.
1.What is an expression?
Expression is a part of code or a content to produce a value.
2.What is a binding?
Bindings are tentacles that grasp value provided it has referenced to that value . Bindings do not contain values.
3.What is an environment?
collection of bindings and their values at a given point of time is called environment.
eg ;- Web browser is an environment which has default function for interaction with surroundings .
- What is a function?
Function is a piece of program wrapped in a value which performs specific task.
5.Give an example of a function.
e.g alert (" hello world")
6.What is a side effect?
When a statement or function modifies the state of something else (outside its own scope), then it is producing a side effect.
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)) ;
8.What is control flow?
its the order of execution of the statements in a program .
- What is conditional execution?
Conditional execution is a program which is executed if only certain conditions hold.
10.What kind of keyword do you need to use to invoke conditional execution?
if else statement , while loops statement , for loops are used for conditional execution.
1. What is an expression?
An expression is a piece of code that returns a value.
2. What is a binding?
A binding is a connection the programmer makes between two values. One value gives direction to the other.
3. What is an environment?
Refers to the collection of bindings that have been made within the program to this point.
4. What is a function?
A function executes a specific task. It can be called upon through the program.
5. Give an example of a function.
console.log(âexampleâ);
6. What is a side effect?
Is an observable change in the program.
7. Give an example of a function that produces a side effect and another function that produces a value.
JavaScript Functions
This example calls a function which performs a calculation, and returns the result:
function myFunction(p1, p2) {
return âLetâs forget about Math and Play a Video Gameâ;
}
document.getElementById(âdemoâ).innerHTML = myFunction(5, 7);
8. What is control flow?
The control flow is the order in which the computer executes statements in a script.
9. What is conditional execution?
An if/else statement is a conditional statement which performs different actions based on different conditions.
10. What kind of keyword do you need to use to invoke conditional execution?
âifâ is the keyword to invoke a conditional execution.
-
What is an expression?
A piece of code that produces value. -
What is a binding?
A variable that is assigned a value -
What is an environment?
A collection of binding and their values at a given time. -
What is a function?
A piece of of program wrapped in a value. -
Give an example of a function.
The binding âpromptâ is a binding that uses a function that takes in user input. -
What is a side effect?
Side effects are items such as a dialog box or writing text to a screen. -
Give an example of a function that produces a side effect and another function that produces a value.
prompt() is a function that produces a side effect and console.log() is a function that produces a value. -
What is control flow?
A multiple statement program with a flow from top to bottom. -
What is conditional execution?
Depending on the situation, the program takes a specific branch to arrive at a final point. -
What kind of keyword do you need to use to invoke conditional exec
âifâ is a keyword.
- A fragment of code that produces a value.
- A special word defines a Binding which grasp and holds in an internal state a value, but can be changed/disconnected from its present value by an a operator.
- When you open a program in ur computer the language standards allows you to interact with the surrounding system which has a collection of bindings and values that exist at a given time.
- Functions are a piece of program wrapped in a value that can be applied/invoked/called to run a wrapped program.
- prompt(âEnter passcodeâ); variable something=("")
- Side effects are produced by functions like a written text return or showing a dialog box unless that fuction produces a value.
7.prompt(âEnter passcodeâ); will produced side effect. console.log will produce a value. - A program that contains more than one statement that can be executed is the control flow of of said program.
- Conditional execution use logic to produce an output, when certain conditions are met they produce the invoked output but if conditions are not met they loop until said condition is met.
- if, else. while, for. do