JavaScript презентация

Which one is legal? My_variable $my_variable 1my_example _my_variable @my_variable My_variable_example ++my_variable %my_variable #my_variable ~my_variable myVariableExample

Слайд 1Lecture 8
JavaScript
Senior-Lecturer: Sarsenova Zh.N.


Слайд 2Which one is legal?
My_variable
$my_variable
1my_example
_my_variable
@my_variable
My_variable_example
++my_variable
%my_variable
#my_variable
~my_variable
myVariableExample


Слайд 3For Loop
A loop is a block of code that allows you

to repeat a section of code a certain number of times, perhaps changing certain variable values each time the code is executed.


Слайд 4Why loops are useful?
Loops are useful because they allow you to

repeat lines of code without retyping them or using cut and paste in your text editor.
They save time and trouble of repeatedly typing the same lines of code, but also avoids typing errors in repeated lines.
You are also able to change one or more variable values each time the browser passes through the loop.


Слайд 5For loop
for (initial_expression; test_exp; change_exp)
{ statements; }
One of the most used

and familiar loops is the for loop.
It iterates through a sequence of statements for a number of times controlled by a condition.
The change_exp determines how much has been added or subtracted from the counter variable.


Слайд 6For loop
for ( varname=1;varname

the rate at which the variable is changed and whether it gets larger or smaller

Слайд 7For loop Example

var counter;
for (counter = 1; counter

counter++)
{
document.write(counter*counter + “ “);
}


Display the square of numbers
Output: 1 4 9 16 25 36 49 64 81 100


Слайд 8A while loop just looks at a short comparison and repeats

until the comparison is no longer true.
The while loop begins with a termination condition and keeps looping until the termination condition is met.
The counter variable is managed by the context of the statements inside the curly braces.


while(varname<11)
{
}

While loop


Слайд 9While loop example


While loop example

var counter = 100;
var numberlist =

“”;
while (counter > 0) {
numberlist += “Number “ + counter + “
”;
counter -= 10;
}
document.write(numberlist);




Слайд 10Do…while loop
The do/while loop always executes statements in the loop in

the first iteration of the loop.
The termination condition is placed at the bottom of the loop.
Syntax:
do {
statements;
counter increment/decrement;
} while (termination condition)


Слайд 11Do…while example


Слайд 12Array
An Array contains a set of data represented by a single

variable name.
Arrays in JavaScript are represented by the Array Object, we need to “new Array()” to construct this object.
The first element of the array is “Array[0]” until the last one Array[i-1].
E.g. myArray = new Array(5)
We have myArray[0,1,2,3,4].


Слайд 13Array Example

Car = new Array(3);
Car[0] = “Ford”;
Car[1] = “Toyota”;
Car[2] =

“Honda”;
document.write(Car[0] + “
”);
document.write(Car[1] + “
”);
document.write(Car[2] + “
”);



Слайд 14Array
You can also declare arrays with variable length.
arrayName = new Array();
Length

= 0, allows automatic extension of the length.
Car[9] = “Ford”; Car[99] = “Honda”;


Слайд 15Events
The most exciting JavaScript-powered pages are dynamic. Which means they perform

various actions as your visitor interacts with them(moving his mouse, typing in the text, clicking things, and so on).
Events are notifications that an HTML element sends out when specific things happen
An HTML event can be something the browser does, or something a user does.
Examples
An HTML web page has finished loading
An HTML input field was changed
An HTML button was clicked


Слайд 17Common HTML Events
The other events we can find here: https://www.w3schools.com/jsref/dom_obj_event.asp


Слайд 18Example


Слайд 19Common HTML object events


Слайд 20Onclick event


Слайд 21Exercise
When the button is clicked, trigger myFunction() with an event.


Слайд 22Mouse Events


Слайд 23Keyboard Events


Слайд 24onFocus event


Слайд 25onblur event
Execute a JavaScript when a user leaves an input field:


Слайд 26onchange event


Слайд 27Frame/Object Events


Слайд 28Form Events


Слайд 29Thank you!


Обратная связь

Если не удалось найти и скачать презентацию, Вы можете заказать его на нашем сайте. Мы постараемся найти нужный Вам материал и отправим по электронной почте. Не стесняйтесь обращаться к нам, если у вас возникли вопросы или пожелания:

Email: Нажмите что бы посмотреть 

Что такое ThePresentation.ru?

Это сайт презентаций, докладов, проектов, шаблонов в формате PowerPoint. Мы помогаем школьникам, студентам, учителям, преподавателям хранить и обмениваться учебными материалами с другими пользователями.


Для правообладателей

Яндекс.Метрика