JavaScript: The prototype Property
-
Upload
guille-paz -
Category
Education
-
view
1.013 -
download
3
description
Transcript of JavaScript: The prototype Property
![Page 1: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/1.jpg)
JavaScript The prototype Property
Thursday, November 1, 12
![Page 2: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/2.jpg)
Brief
What’s OOP?
JavaScript OOP
Prototype
Inheritance
Thursday, November 1, 12
![Page 3: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/3.jpg)
What’s OOP?Introducir a OOP
Presentar el vocabulario
Thursday, November 1, 12
![Page 4: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/4.jpg)
Object Oriented Programming
Thursday, November 1, 12
![Page 5: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/5.jpg)
Programming paradigm
Thursday, November 1, 12
![Page 6: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/6.jpg)
Data abstraction
Encapsulation
Messaging
Modularity
Polymorphism
Inheritance
Thursday, November 1, 12
![Page 7: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/7.jpg)
Use object based on the real world
Thursday, November 1, 12
![Page 8: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/8.jpg)
Class vs Object
Thursday, November 1, 12
![Page 9: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/9.jpg)
Class
A Class defines Objects
Properties
An object characteristic, such as color
Methods
An object capability, such as walk
Thursday, November 1, 12
![Page 10: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/10.jpg)
Objects
A instance of a Class
Share properties and behavior
Unique
Thursday, November 1, 12
![Page 11: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/11.jpg)
Class
Thursday, November 1, 12
![Page 12: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/12.jpg)
Class
Object1
Thursday, November 1, 12
![Page 13: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/13.jpg)
Class
Object1 Object2
Thursday, November 1, 12
![Page 14: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/14.jpg)
Class
Object1 Object2 Object3
Thursday, November 1, 12
![Page 15: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/15.jpg)
Exercise
Thursday, November 1, 12
![Page 16: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/16.jpg)
JavaScript OOPAplicar JavaScript OOP
Thursday, November 1, 12
![Page 17: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/17.jpg)
JavaScript is a prototypal language
Thursday, November 1, 12
![Page 18: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/18.jpg)
Prototype-based programming
Class free
Classes are not present
Not Object Oriented
Everything is public
Objects inherits from another objects
Thursday, November 1, 12
![Page 19: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/19.jpg)
Objects in JavaScript
Thursday, November 1, 12
![Page 20: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/20.jpg)
Everything is an object
Thursday, November 1, 12
![Page 21: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/21.jpg)
Everything is an object
Arrays
ArraysThursday, November 1, 12
![Page 22: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/22.jpg)
Everything is an object
Arrays
Arrays
Dates
Thursday, November 1, 12
![Page 23: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/23.jpg)
Everything is an object
Arrays
Objects
Arrays
Dates
Thursday, November 1, 12
![Page 24: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/24.jpg)
Everything is an object
Arrays
Objects
Arrays
Dates
Strings
Thursday, November 1, 12
![Page 25: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/25.jpg)
Everything is an object
Arrays
Objects
Arrays
Numbers
Dates
Strings
Thursday, November 1, 12
![Page 26: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/26.jpg)
They have methods and properties
Thursday, November 1, 12
![Page 27: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/27.jpg)
Thursday, November 1, 12
![Page 28: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/28.jpg)
Thursday, November 1, 12
![Page 29: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/29.jpg)
Thursday, November 1, 12
![Page 30: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/30.jpg)
Thursday, November 1, 12
![Page 31: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/31.jpg)
Custom Objects
Thursday, November 1, 12
![Page 32: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/32.jpg)
Thursday, November 1, 12
![Page 33: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/33.jpg)
Thursday, November 1, 12
![Page 34: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/34.jpg)
Thursday, November 1, 12
![Page 35: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/35.jpg)
Thursday, November 1, 12
![Page 36: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/36.jpg)
Thursday, November 1, 12
![Page 37: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/37.jpg)
Thursday, November 1, 12
![Page 38: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/38.jpg)
Thursday, November 1, 12
![Page 39: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/39.jpg)
Thursday, November 1, 12
![Page 40: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/40.jpg)
Thursday, November 1, 12
![Page 41: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/41.jpg)
Not reuse
Thursday, November 1, 12
![Page 42: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/42.jpg)
Not reuse
Unique
Thursday, November 1, 12
![Page 43: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/43.jpg)
Not reuse
Unique
Singleton Pattern
Thursday, November 1, 12
![Page 44: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/44.jpg)
Exercise
Thursday, November 1, 12
![Page 45: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/45.jpg)
Constructors
Thursday, November 1, 12
![Page 46: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/46.jpg)
Constructor
Functions
Classes
Create diferents instances ==> Objects
Use new operator
Accepts parameters
Returns an instance ==> Object
Thursday, November 1, 12
![Page 47: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/47.jpg)
Thursday, November 1, 12
![Page 48: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/48.jpg)
Thursday, November 1, 12
![Page 49: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/49.jpg)
Constructor
Has properties and methods
length
constructor
apply()
call()
prototype
Thursday, November 1, 12
![Page 50: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/50.jpg)
Thursday, November 1, 12
![Page 51: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/51.jpg)
Prototype
Thursday, November 1, 12
![Page 52: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/52.jpg)
Prototype
A property
Defines properties and methods to all instances
Works with new operator
Stored in the memory once
Contain an Object
initial value === empty Object === {}
Thursday, November 1, 12
![Page 53: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/53.jpg)
Thursday, November 1, 12
![Page 54: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/54.jpg)
Thursday, November 1, 12
![Page 55: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/55.jpg)
Thursday, November 1, 12
![Page 56: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/56.jpg)
Thursday, November 1, 12
![Page 57: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/57.jpg)
Thursday, November 1, 12
![Page 58: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/58.jpg)
Thursday, November 1, 12
![Page 59: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/59.jpg)
Thursday, November 1, 12
![Page 60: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/60.jpg)
Inheritance
Thursday, November 1, 12
![Page 61: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/61.jpg)
Inheritance
A new “class” is created from another “class”
Extends functionality
Defines new attributes and methods
A way to reuse code
All Object inherit from Object.prototype
12+ ways to inherits in JS
Thursday, November 1, 12
![Page 62: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/62.jpg)
Prototype ChainingPseudo-clasical
Thursday, November 1, 12
![Page 63: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/63.jpg)
Thursday, November 1, 12
![Page 64: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/64.jpg)
Thursday, November 1, 12
![Page 65: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/65.jpg)
Thursday, November 1, 12
![Page 66: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/66.jpg)
Thursday, November 1, 12
![Page 67: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/67.jpg)
Thursday, November 1, 12
![Page 68: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/68.jpg)
Thursday, November 1, 12
![Page 69: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/69.jpg)
Thursday, November 1, 12
![Page 70: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/70.jpg)
Thursday, November 1, 12
![Page 71: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/71.jpg)
Thursday, November 1, 12
![Page 72: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/72.jpg)
Thursday, November 1, 12
![Page 73: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/73.jpg)
Thursday, November 1, 12
![Page 74: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/74.jpg)
Inherited
Thursday, November 1, 12
![Page 75: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/75.jpg)
Inherited
Thursday, November 1, 12
![Page 76: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/76.jpg)
Own
Thursday, November 1, 12
![Page 77: JavaScript: The prototype Property](https://reader037.fdocuments.net/reader037/viewer/2022103013/5452faa4af7959ce428b5a5c/html5/thumbnails/77.jpg)
The End
Thursday, November 1, 12