Upload
satyen-pandya
View
217
Download
0
Embed Size (px)
Citation preview
8/7/2019 JavaScript Object Basics By Satyen
1/11
By: Satyen Pandya
[email protected]@gmail.com
JavaScriptJavaScript Object BasicsObject Basics
8/7/2019 JavaScript Object Basics By Satyen
2/11
ContentsContents
2
Object-Oriented Terminology
Early v/s. Late Binding
Types ofObjects
Defining Classes & Objects
Modifying Objects
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
3/11
ObjectObject--Oriented TerminologyOriented Terminology
3
ECMA-262 defines Object as an unordered collection of
properties each of which contains a primitive value,
object or function
Fourbasic features ofOOP:
1. Encapsulation
2. Aggregation
3. Inheritance
4. Polymorphism
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
4/11
Early versus Late BindingEarly versus Late Binding
4
Binding the method whereby an objects interface is
bound to an object instance
Early Binding Properties and methods are defined for
an object before it is instantiated
Late Binding The compiler/interpreter doesnt know
what type of object is being held until runtime
ECMAScript doesnt support early binding
ECMAScript uses late binding for all variables
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
5/11
Types of ObjectsTypes of Objects
5
Three types of objects can be used/created :
1. Native Objects
2. Built-in Objects
3. Host Objects
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
6/11
Types of Objects (Contd)Types of Objects (Contd)
6
Native Objects : any object supplied by an ECMAScript
implementation independent of the host environment
All the native objects includes a list ofbuilt-in functions
and properties
They includes :Array EvalError RangeError SyntaxError
Boolean Function ReferenceError TypeError
Date Number RegEcp URIError
Error Object String
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
7/11
Types of Objects (Contd)Types of Objects (Contd)
7
Built-in Objects : Object which is present at the start of
execution of ECMAScript program
It is already instantiated
ECMA-262 defines only two objects :
1. Global
2. Math Global includes functions like, isNan(), isFinite(), parseInt(),
parseFloat(), etc.
- properties like, undefined, NaN, Infinity, Constructors for
all Native Objects
Math includes functions like, max(), min(), ceil(), round(),
floor(), etc.
- properties like, E, LN10, LOG2E, LOG10E, PI, SQRT1_2,
SQRT2
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
8/11
Types of Objects (Contd)Types of Objects (Contd)
8
Host Objects : any object that is not a native
All BOM and DOM objects are host objects
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
9/11
Defining Classes & ObjectsDefining Classes & Objects
9
Classes can be defined same as function
We can define class in different ways :
1. Factory paradigm
2. Constructor paradigm
3. Prototype paradigm
4. Hybrid constructor/prototype paradigm
5. Dynamic prototype
6. Hybrid factory paradigm
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
10/11
Modifying ObjectsModifying Objects
10
Objects can be modified by using prototype property
We can modify object in different ways :
1. Creating a new method
2. Redefining an existing method
3. Very late binding
[email protected]@gmail.com
8/7/2019 JavaScript Object Basics By Satyen
11/11
Thank youThank you
By: Satyen Pandya
[email protected]@gmail.com