Page 133 - CITS - Computer Software Application -TT
P. 133
COMPUTER SOFTWARE APPLICATION - CITS
// Illustration of function* expression
// use of function* keyword
function* func() {
yield 1;
yield 2;
yield 3;
yield “ - Nsti”;
}
let obj = ‘’;
// Function calling
for (const i of func()) {
obj = obj + i;
}
// Output
console.log(obj);
Output
123 – Nsti
JavaScript Expressions
An expression is a combination of values, variables, and operators, which computes to a value.
The computation is called an evaluation.
For example, 5 * 10 evaluates to 50:
5 * 10
Expressions can also contain variable values:
x * 10
The values can be of various types, such as numbers and strings.
For example, “John” + “ “ + “Doe”, evaluates to “John Doe”:
“John” + “ “ + “Doe”
JavaScript Keywords
JavaScript keywords are used to identify actions to be performed.
The let keyword tells the browser to create variables:
let x, y;
x = 5 + 6;
y = x * 10;
The var keyword also tells the browser to create variables:
var x, y;
x = 5 + 6;
y = x * 10;
In these examples, using var or let will produce the same result.
You will learn more about var and let later in this tutorial.
120
CITS : IT&ITES - Computer Software Application - Lesson 37 - 46