Презентация Using objects in JavaScript. Accessing DOM in JavaScript онлайн

На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Using objects in JavaScript. Accessing DOM in JavaScript абсолютно бесплатно. Урок-презентация на эту тему содержит всего 53 слайда. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » Using objects in JavaScript. Accessing DOM in JavaScript



Оцените!
Оцените презентацию от 1 до 5 баллов!
  • Тип файла:
    ppt / pptx (powerpoint)
  • Всего слайдов:
    53 слайда
  • Для класса:
    1,2,3,4,5,6,7,8,9,10,11
  • Размер файла:
    2.22 MB
  • Просмотров:
    72
  • Скачиваний:
    0
  • Автор:
    неизвестен



Слайды и текст к этой презентации:

№1 слайд
Using objects in JavaScript.
Содержание слайда: Using objects in JavaScript. Accessing DOM in JavaScript Vyacheslav Koldovskyy Last update: 29/03/2016

№2 слайд
Agenda Program flow control
Содержание слайда: Agenda Program flow control Collections Custom objects Constructors Context and "this" Operator "new" Browser Object Model (BOM) and Document Object Model (DOM) Events Memory and Sandbox Closures

№3 слайд
Conditions if-else Syntax if
Содержание слайда: Conditions: if-else Syntax: if (condition) statement1 [else statement2] Example:

№4 слайд
Conditional Ternary Operator
Содержание слайда: Conditional (Ternary) Operator ?: Syntax: condition ? expr1 : expr2 Example:

№5 слайд
Loops for
Содержание слайда: Loops: for

№6 слайд
Loops while and do-while
Содержание слайда: Loops: while and do-while

№7 слайд
Loops keywords break and
Содержание слайда: Loops: keywords break and continue There are two keywords for loops control : break – aborts loop and moves control to next statement after the loop; continue – aborts current iteration and immediately starts next iteration. Try not to use this keywords. A good loop have one entering point, one condition and one exit.

№8 слайд
Switch Switch statement
Содержание слайда: Switch Switch statement allows to select one of many blocks of code to be executed. If all options don’t fit, default statements will be processed

№9 слайд
Collections Collection is a
Содержание слайда: Collections Collection is a set of variables grouped under common name. Usually elements of collections are grouped according to some logical or physical characteristic. Collections help to avoids situations when we have to declare multiple variables with similar names:: var a1, a2, a3, a4… There are two types of collections that are typical for JS: arrays and dictionaries (hash tables).

№10 слайд
Array processing Usage of
Содержание слайда: Array: processing Usage of arrays: var array = [] // declaration of empty array var array = [5, 8, 16] // declaration of predefined array array[0] = 4; // writing value with index 0 tmp = array[2]; // reading value by index (in tmp - 16) array.length // getting length of array

№11 слайд
Array features Arrays in
Содержание слайда: Array: features Arrays in JavaScript differ from arrays in classical languages. Arrays in JS are instances of Object. So Array in JS can be easily resized, can contain data of different types and have string as an index. Length of array is contained in length property, its value is equal to index of last element increased by one.

№12 слайд
Array useful methods
Содержание слайда: Array: useful methods

№13 слайд
Iterating an Array
Содержание слайда: Iterating an Array

№14 слайд
Dictionary Dictionaries allow
Содержание слайда: Dictionary Dictionaries allow us to have set of data in form of "key-value" pairs We can create hash and initialize it at the same time. For this we should write values separated by a comma like in array. But for all values we have to set key:

№15 слайд
Using Dictionary Usage of
Содержание слайда: Using Dictionary Usage of dictionaries tables is very similar to arrays: dict['good'] = 4; // writing value in element with key “good” tmp = dict['excellent']; // reading value by key “excellent” The difference is in usage of for-in statement:

№16 слайд
Array vs Dictionary Use Array
Содержание слайда: Array vs Dictionary Use Array for collections with digital indexes. Use Hash if you want use string keys. Don't look for property length in Hash. Don't look for forEach and other Array methods in Hash. Always explicitly declare Array otherwise you get a Hash. Don't use for with hash, use for-in instead. At finally : use collection – be cool :)

№17 слайд
Object creation You know that
Содержание слайда: Object creation You know that we can create a simple object in JavaScript. We use JSON for this.

№18 слайд
Object or Dictionary But this
Содержание слайда: Object or Dictionary But this way it looks like hash table creation. What is the difference between hash table and object, then?

№19 слайд
Object or Dictionary
Содержание слайда: Object or Dictionary Typically we use hash table if we want to represent some collection, and we use an object to describe some system or entity.

№20 слайд
Difference in use
Содержание слайда: Difference in use

№21 слайд
Constructors Sometimes we
Содержание слайда: Constructors Sometimes we need to create more than one single object. It is not a good idea to use the literal way for this. It will be better create a scenario for objects reproducing. Constructor is a function that implements this scenario in JavaScript. Constructor consists of declaration attributes and methods that should be added into each new object with presented structure.

№22 слайд
Constructors example
Содержание слайда: Constructors: example

№23 слайд
BOM and DOM
Содержание слайда: BOM and DOM

№24 слайд
Description How JavaScript
Содержание слайда: Description How JavaScript communicates with the world? In outline this mechanism works by next scenario: user does something and this action is an event for browser. JavaScript observes pages in the browser. And if event has occurred, script will be activated.

№25 слайд
Event handling But JavaScript
Содержание слайда: Event handling But JavaScript doesn't observe events by default. You should specify to your code what events are interesting for it. There are 3 basic ways to subscribe to an event: - inline in HTML - using of onevent attribute using special methods First and second ways are deprecated for present days. Let's take a look at event handling in more details.

№26 слайд
Inline handling
Содержание слайда: Inline handling

№27 слайд
Using of onevent attribute
Содержание слайда: Using of onevent attribute

№28 слайд
Proper ways
Содержание слайда: Proper ways

№29 слайд
Proper ways
Содержание слайда: Proper ways

№30 слайд
Bubbling and Capturing
Содержание слайда: Bubbling and Capturing

№31 слайд
Bubbling and Capturing
Содержание слайда: Bubbling and Capturing

№32 слайд
Event object For every event
Содержание слайда: Event object For every event in the browser instance of Event object will be created.

№33 слайд
Control of Default behavior
Содержание слайда: Control of Default behavior Sometimes a default scenario of event processing includes some additional behavior: bubbling and capturing or displaying context menu.

№34 слайд
Sample
Содержание слайда: Sample

№35 слайд
Practice Task
Содержание слайда: Practice Task

№36 слайд
Advanced
Содержание слайда: Advanced

№37 слайд
Содержание слайда:

№38 слайд
Context Let s imagine two
Содержание слайда: Context Let's imagine two identical objects. They are created by Cat constructor:

№39 слайд
Context If we call method run
Содержание слайда: Context If we call method run() for both cats, we’ll take correct results:

№40 слайд
Context It works because we
Содержание слайда: Context It works because we use the next form of access to attribute name: this.name. this contains inside a reference to object on whose behalf was called method run. Such a reference is called a context. The context determined automatically after the method calling and can't be changed by code.

№41 слайд
Loss of context Be careful!
Содержание слайда: Loss of context Be careful! There are situations when you can lose a context. For example:

№42 слайд
Содержание слайда:

№43 слайд
Basic info Free space in
Содержание слайда: Basic info Free space in browser sandbox is allocated for each variable in JavaScript. Sandbox is a special part of memory that will be managed by browser: JavaScript takes simplified and secure access to "memory“, browser translates JS commands and does all low-level work. As a result memory, PC and user data has protection from downloaded JavaScript malware.

№44 слайд
Scope The scope is a special
Содержание слайда: Scope The scope is a special JavaScript object which was created by browser in the sandbox and used for storing variables. Each function in JavaScript has its own personal scope. Scope is formed when a function is called and destroyed after the function finishes. This behavior helps to manage local variables mechanism. Object window is a top-level scope for all default and global variables.

№45 слайд
Scope
Содержание слайда: Scope

№46 слайд
Value-types and
Содержание слайда: Value-types and Reference-types Unfortunately some objects are too large for scope. For example string or function. There is simple division into value-types and reference-types for this reason. Value-types are stored in scope completely and for reference-types only reference to their location is put in scope. They themselves are located in place called "memory heap". String and all Objects are reference-types. Other data types are stored in scope.

№47 слайд
Memory cleaning The basic
Содержание слайда: Memory cleaning The basic idea of memory cleaning: when function is finished, scope should be destroyed and as a result all local variables should be destroyed. This will work for value-types. As for reference-types: deleting the scope destroys only reference. The object in heap itself will be destroyed only when it becomes unreachable.

№48 слайд
Unreachable links An object
Содержание слайда: Unreachable links An object is considered unreachable if it is not referenced from the client area of code. Garbage collector is responsible for the cleanup of unreachable objects. It's a special utility that will launch automatically if there isn’t enough space in the sandbox. If an object has at least one reference it is still reachable and will survive after memory cleaning.

№49 слайд
Unreachable links
Содержание слайда: Unreachable links

№50 слайд
Содержание слайда:

№51 слайд
Closure If scope is an object
Содержание слайда: Closure If scope is an object and it is not deleted it is still reachable, isn't it? Absolutely! This mechanism is called closure. If you save at least one reference to scope, all its content will survive after function finishing.

№52 слайд
Example
Содержание слайда: Example

№53 слайд
Contacts
Содержание слайда: Contacts

Скачать все slide презентации Using objects in JavaScript. Accessing DOM in JavaScript одним архивом: