FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.
Email: Нажмите что бы посмотреть
[1]
[2]
[3]
A process in which a variable is set to its first value is called initialization.
[1]
[2]
[3]
Or quickly
var variable = 10;
[1]
[2]
[3]
[1]
[2]
var s = “text”; or var s = String(“text”);
//string values for example: “”, “text”, ‘text’
var b = true; or var b = Boolean(true);
//bollean values: true and false
[1]
[2]
[3]
And Object type… but it will be reviewed in future :)
[1]
There are two types of casting:
Implicit
Explicit
But both ways given c =11 as a result!
[2]
[1]
[3]
[1]
[2]
[3]
[4]
[1]
[2]
y = f(x)
Function is a named part of a code that performs a distinct service.
[1]
[2]
[3]
[4]
[5]
[2]
[3]
[3]
[1]
[2]
[3]
1.
1.
2.
3.
1.
2.
3.
4.
5.
6.
1.
2.
3.
4.
5.
6.
5.1
5.2
[2]
[1]
[2]
[3]
[4]
[1]
[2]
if (condition) {
true branch;
} else {
false branch;
}
if (condition) {
true branch;
}
[1]
[2]
[3]
Function get a parameter with a information about discount. And if discount is "silver" or "gold“, function modifies global variable price.
In this example a shortened form of operator was used.
result = (condition)? true action: false action;
Let’s rewrite the last example using ternary operator.
[1]
function discount (type) {
price *= (type === “silver”)? 0.9: 1;
price *= (type === “gold”)? 0.85: 1;
return price;
}
We get a more compact but a less readable code. So be careful!
One processing of loop’s body is called iteration.
[1]
[2]
[3]
do {
body of loop;
} while (condition);
The main difference between these loops is the moment of condition calculation. While calculates condition, and if the result is true, while does iteration. Do-while initially does iteration and after that calculates a condition.
[1]
[2]
Text with number of current iteration will be print 5 times
Example 2:
while (accumulation < 100) {
accumulation += doSomething();
}
This loop will be repeated until accumulation reaches 100 or gets grater value.
[1]
[2]
switch (statement) {
case value1: some body;
break;
case value2: some body;
break;
. . .
default: some body;
}
switch (mark) {
case 5: result = “excellent”;
break;
case 4: result = “good”;
break;
case 3: result = “satisfactorily”;
break;
case 2: result = “bad”;
break;
}