SlideShare a Scribd company logo
Object-Oriented
JavaScript



     Learn More @ http://www.learnnowonline.com
        Copyright © by Application Developers Training Company
Objectives




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Objectives
• Learn about the various ways to create
  new objects with JavaScript




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Objectives
• Learn about the various ways to create
  new objects with JavaScript
• Explore how you can create custom
  constructors to instantiate multiple
  objects of the same class




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Introduction to
Object-Oriented JavaScript




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Introduction to
Object-Oriented JavaScript
• Possible to build sophisticated
  frameworks




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Introduction to
Object-Oriented JavaScript
• Possible to build sophisticated
  frameworks
  • jQuery for general Web development




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Introduction to
Object-Oriented JavaScript
• Possible to build sophisticated
  frameworks
  • jQuery for general Web development
• OOP uses abstraction to create models
  of real objects




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Introduction to
Object-Oriented JavaScript
• Possible to build sophisticated
  frameworks
  • jQuery for general Web development
• OOP uses abstraction to create models
  of real objects
  • Store own data and state




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Introduction to
Object-Oriented JavaScript
• Possible to build sophisticated
  frameworks
  • jQuery for general Web development
• OOP uses abstraction to create models
  of real objects
  • Store own data and state
  • Receive messages




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Introduction to
Object-Oriented JavaScript
• Possible to build sophisticated
  frameworks
  • jQuery for general Web development
• OOP uses abstraction to create models
  of real objects
  • Store own data and state
  • Receive messages
  • Interact with other objects


          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• Introduction to Object-Oriented
  JavaScript




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction to Object-Oriented
  JavaScript
• Creating JavaScript Objects




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction to Object-Oriented
  JavaScript
• Creating JavaScript Objects
• Custom Object Constructors




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating JavaScript Objects




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Creating JavaScript Objects
• Number of ways to create custom
  objects




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating JavaScript Objects
• Number of ways to create custom
  objects
• Customer object




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating JavaScript Objects
• Number of ways to create custom
  objects
• Customer object
  • Properties to record data like ID, name,
   location




          Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Creating JavaScript Objects
• Number of ways to create custom
  objects
• Customer object
  • Properties to record data like ID, name,
   location
    • Some direct properties, others getter/setters




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Creating JavaScript Objects
• Number of ways to create custom
  objects
• Customer object
  • Properties to record data like ID, name,
   location
    • Some direct properties, others getter/setters
  • Override Object.toString




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Creating JavaScript Objects
• Number of ways to create custom
  objects
• Customer object
  • Properties to record data like ID, name,
   location
    • Some direct properties, others getter/setters
  • Override Object.toString
  • Method to record sales



           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Using the Object Constructor




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Using the Object Constructor
• Use Object constructor with new
  keyword




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using the Object Constructor
• Use Object constructor with new
  keyword
  • Creates a new object that inherits from
   Object




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Using the Object Constructor
• Use Object constructor with new
  keyword
  • Creates a new object that inherits from
    Object
  • No arguments: new object




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using the Object Constructor
• Use Object constructor with new
  keyword
  • Creates a new object that inherits from
    Object
  • No arguments: new object
  • Primitive type argument: create new
    Number, Boolean, or String object



          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using an Object Literal




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Using an Object Literal
• Notable differences from Object
  constructor technique:




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Using an Object Literal
• Notable differences from Object
  constructor technique:
  • Single statement




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using an Object Literal
• Notable differences from Object
  constructor technique:
  • Single statement
     var customer = { };




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using an Object Literal
• Notable differences from Object
  constructor technique:
  • Single statement
     var customer = { };
  • Adding properties




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using an Object Literal
• Notable differences from Object
  constructor technique:
  • Single statement
     var customer = { };
  • Adding properties
  • Defining getters and setters




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Creating an Object Hierarchy
with Prototypes




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Creating an Object Hierarchy
with Prototypes
• Can use customer as a prototype for
  other objects




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating an Object Hierarchy
with Prototypes
• Can use customer as a prototype for
  other objects
  • New objects inherit properties of the base
   object




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Creating an Object Hierarchy
with Prototypes
• Can use customer as a prototype for
  other objects
  • New objects inherit properties of the base
    object
  • Called the prototype of the new objects




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Creating an Object Hierarchy
with Prototypes
• Can use customer as a prototype for
  other objects
  • New objects inherit properties of the base
    object
  • Called the prototype of the new objects
  • Set of objects with same prototype is a
    class



          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Object Identity




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Object Identity
• Can use the isPrototypeOf method




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Object Identity
• Can use the isPrototypeOf method
  • See whether one object has another as its
   prototype




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Agenda




     Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Agenda
• Introduction to Object-Oriented
  JavaScript




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction to Object-Oriented
  JavaScript
• Creating JavaScript Objects




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Agenda
• Introduction to Object-Oriented
  JavaScript
• Creating JavaScript Objects
• Custom Object Constructors




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Custom Object Constructors




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Custom Object Constructors
• Constructor is a function that
  initializes an object




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Custom Object Constructors
• Constructor is a function that
  initializes an object
  • Used with the new keyword




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Custom Object Constructors
• Constructor is a function that
  initializes an object
  • Used with the new keyword
     • This actually creates the object




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Custom Object Constructors
• Constructor is a function that
  initializes an object
  • Used with the new keyword
     • This actually creates the object
• Constructor’s prototype object
  becomes prototype of new object




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Custom Object Constructors
• Constructor is a function that
  initializes an object
  • Used with the new keyword
     • This actually creates the object
• Constructor’s prototype object
  becomes prototype of new object
  • So all objects created with the constructor
    share prototypes


            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Custom Object Constructors
• Constructor is a function that
  initializes an object
  • Used with the new keyword
     • This actually creates the object
• Constructor’s prototype object
  becomes prototype of new object
  • So all objects created with the constructor
    share prototypes
     • So all are members of the same class


            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Creating a New Constructor
Prototype Object




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Creating a New Constructor
Prototype Object
• Sample modified constructor’s default
  prototype object




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating a New Constructor
Prototype Object
• Sample modified constructor’s default
  prototype object
• Alternatively, can create a whole new
  object




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Creating a New Constructor
Prototype Object
• Sample modified constructor’s default
  prototype object
• Alternatively, can create a whole new
  object
  • Slightly cleaner code




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Creating a New Constructor
Prototype Object
• Sample modified constructor’s default
  prototype object
• Alternatively, can create a whole new
  object
  • Slightly cleaner code
     • Implement as single statement




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Creating a New Constructor
Prototype Object
• Sample modified constructor’s default
  prototype object
• Alternatively, can create a whole new
  object
  • Slightly cleaner code
     • Implement as single statement
     • Cleaner syntax




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Dynamically Changing the Prototype
of a Class




         Learn More @ http://www.learnnowonline.com
            Copyright © by Application Developers Training Company
Dynamically Changing the Prototype
of a Class
 • Benefit of using a prototype is you can
   dynamically change it




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Dynamically Changing the Prototype
of a Class
 • Benefit of using a prototype is you can
   dynamically change it
   • Automatically changes all objects in the
    class




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Dynamically Changing the Prototype
of a Class
 • Benefit of using a prototype is you can
   dynamically change it
   • Automatically changes all objects in the
     class
   • Object inherits from prototype even when
     prototype subsequently changes




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Dynamically Changing the Prototype
of a Class
 • Benefit of using a prototype is you can
   dynamically change it
   • Automatically changes all objects in the
     class
   • Object inherits from prototype even when
     prototype subsequently changes
   • Can even modify prototypes of built-in
     objects


           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Object Identity with
Constructors




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Object Identity with
Constructors
 • instanceof operator




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Object Identity with
Constructors
 • instanceof operator
   • Determine whether an object is an instance
    created by a constructor




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Object Identity with
Constructors
 • instanceof operator
   • Determine whether an object is an instance
     created by a constructor
   • Operands




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Object Identity with
Constructors
 • instanceof operator
   • Determine whether an object is an instance
     created by a constructor
   • Operands
     • Object to test




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Object Identity with
Constructors
 • instanceof operator
   • Determine whether an object is an instance
     created by a constructor
   • Operands
     • Object to test
     • Constructor object to test against




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Object Identity with
Constructors
 • instanceof operator
   • Determine whether an object is an instance
     created by a constructor
   • Operands
     • Object to test
     • Constructor object to test against
   • Pass anything as first operand, but second
    must be a function object




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Object Identity with
Constructors
 • instanceof operator
   • Determine whether an object is an instance
     created by a constructor
   • Operands
      • Object to test
      • Constructor object to test against
   • Pass anything as first operand, but second
     must be a function object
 • Reinforce the idea that constructors are
   the public identity of a class of objects


             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Learn More!




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company

More Related Content

Similar to Object-Oriented JavaScript (20)

SharePoint Document Management
SharePoint Document ManagementSharePoint Document Management
SharePoint Document Management
LearnNowOnline
 
The Entity Data Model
The Entity Data ModelThe Entity Data Model
The Entity Data Model
LearnNowOnline
 
Managing site collections
Managing site collectionsManaging site collections
Managing site collections
LearnNowOnline
 
Bring a Web Page Alive with jQuery
Bring a Web Page Alive with jQueryBring a Web Page Alive with jQuery
Bring a Web Page Alive with jQuery
LearnNowOnline
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
LearnNowOnline
 
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
LearnNowOnline
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity Framework
LearnNowOnline
 
What's new in Silverlight 5
What's new in Silverlight 5What's new in Silverlight 5
What's new in Silverlight 5
LearnNowOnline
 
WPF: Working with Data
WPF: Working with DataWPF: Working with Data
WPF: Working with Data
LearnNowOnline
 
Object oriented techniques
Object oriented techniquesObject oriented techniques
Object oriented techniques
LearnNowOnline
 
KnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVCKnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
Attributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programmingAttributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programming
LearnNowOnline
 
New in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDENew in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDE
LearnNowOnline
 
Generics
GenericsGenerics
Generics
LearnNowOnline
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
LearnNowOnline
 
SQL: Permissions and Data Protection
SQL: Permissions and Data ProtectionSQL: Permissions and Data Protection
SQL: Permissions and Data Protection
LearnNowOnline
 
.NET Variables and Data Types
.NET Variables and Data Types.NET Variables and Data Types
.NET Variables and Data Types
LearnNowOnline
 
.Net branching and flow control
.Net branching and flow control.Net branching and flow control
.Net branching and flow control
LearnNowOnline
 
Getting Started with .NET
Getting Started with .NETGetting Started with .NET
Getting Started with .NET
LearnNowOnline
 
slides.pptx
slides.pptxslides.pptx
slides.pptx
xejoji6654
 
SharePoint Document Management
SharePoint Document ManagementSharePoint Document Management
SharePoint Document Management
LearnNowOnline
 
Managing site collections
Managing site collectionsManaging site collections
Managing site collections
LearnNowOnline
 
Bring a Web Page Alive with jQuery
Bring a Web Page Alive with jQueryBring a Web Page Alive with jQuery
Bring a Web Page Alive with jQuery
LearnNowOnline
 
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
LearnNowOnline
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity Framework
LearnNowOnline
 
What's new in Silverlight 5
What's new in Silverlight 5What's new in Silverlight 5
What's new in Silverlight 5
LearnNowOnline
 
WPF: Working with Data
WPF: Working with DataWPF: Working with Data
WPF: Working with Data
LearnNowOnline
 
Object oriented techniques
Object oriented techniquesObject oriented techniques
Object oriented techniques
LearnNowOnline
 
KnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVCKnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
Attributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programmingAttributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programming
LearnNowOnline
 
New in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDENew in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDE
LearnNowOnline
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
LearnNowOnline
 
SQL: Permissions and Data Protection
SQL: Permissions and Data ProtectionSQL: Permissions and Data Protection
SQL: Permissions and Data Protection
LearnNowOnline
 
.NET Variables and Data Types
.NET Variables and Data Types.NET Variables and Data Types
.NET Variables and Data Types
LearnNowOnline
 
.Net branching and flow control
.Net branching and flow control.Net branching and flow control
.Net branching and flow control
LearnNowOnline
 
Getting Started with .NET
Getting Started with .NETGetting Started with .NET
Getting Started with .NET
LearnNowOnline
 

More from LearnNowOnline (8)

A tour of SQL Server
A tour of SQL ServerA tour of SQL Server
A tour of SQL Server
LearnNowOnline
 
Introducing LINQ
Introducing LINQIntroducing LINQ
Introducing LINQ
LearnNowOnline
 
SharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPathSharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPath
LearnNowOnline
 
SQL Server: Security
SQL Server: SecuritySQL Server: Security
SQL Server: Security
LearnNowOnline
 
Sql 2012 development and programming
Sql 2012  development and programmingSql 2012  development and programming
Sql 2012 development and programming
LearnNowOnline
 
Expression Blend Motion & Interaction Design
Expression Blend Motion & Interaction DesignExpression Blend Motion & Interaction Design
Expression Blend Motion & Interaction Design
LearnNowOnline
 
Working with Controllers and Actions in MVC
Working with Controllers and Actions in MVCWorking with Controllers and Actions in MVC
Working with Controllers and Actions in MVC
LearnNowOnline
 
Creating a User Interface
Creating a User InterfaceCreating a User Interface
Creating a User Interface
LearnNowOnline
 
SharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPathSharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPath
LearnNowOnline
 
Sql 2012 development and programming
Sql 2012  development and programmingSql 2012  development and programming
Sql 2012 development and programming
LearnNowOnline
 
Expression Blend Motion & Interaction Design
Expression Blend Motion & Interaction DesignExpression Blend Motion & Interaction Design
Expression Blend Motion & Interaction Design
LearnNowOnline
 
Working with Controllers and Actions in MVC
Working with Controllers and Actions in MVCWorking with Controllers and Actions in MVC
Working with Controllers and Actions in MVC
LearnNowOnline
 
Creating a User Interface
Creating a User InterfaceCreating a User Interface
Creating a User Interface
LearnNowOnline
 

Recently uploaded (20)

Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 

Object-Oriented JavaScript

  • 1. Object-Oriented JavaScript Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 2. Objectives Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 3. Objectives • Learn about the various ways to create new objects with JavaScript Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 4. Objectives • Learn about the various ways to create new objects with JavaScript • Explore how you can create custom constructors to instantiate multiple objects of the same class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 5. Introduction to Object-Oriented JavaScript Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 6. Introduction to Object-Oriented JavaScript • Possible to build sophisticated frameworks Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 7. Introduction to Object-Oriented JavaScript • Possible to build sophisticated frameworks • jQuery for general Web development Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 8. Introduction to Object-Oriented JavaScript • Possible to build sophisticated frameworks • jQuery for general Web development • OOP uses abstraction to create models of real objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 9. Introduction to Object-Oriented JavaScript • Possible to build sophisticated frameworks • jQuery for general Web development • OOP uses abstraction to create models of real objects • Store own data and state Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 10. Introduction to Object-Oriented JavaScript • Possible to build sophisticated frameworks • jQuery for general Web development • OOP uses abstraction to create models of real objects • Store own data and state • Receive messages Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 11. Introduction to Object-Oriented JavaScript • Possible to build sophisticated frameworks • jQuery for general Web development • OOP uses abstraction to create models of real objects • Store own data and state • Receive messages • Interact with other objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 12. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 13. Agenda • Introduction to Object-Oriented JavaScript Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 14. Agenda • Introduction to Object-Oriented JavaScript • Creating JavaScript Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 15. Agenda • Introduction to Object-Oriented JavaScript • Creating JavaScript Objects • Custom Object Constructors Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 16. Creating JavaScript Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 17. Creating JavaScript Objects • Number of ways to create custom objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 18. Creating JavaScript Objects • Number of ways to create custom objects • Customer object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 19. Creating JavaScript Objects • Number of ways to create custom objects • Customer object • Properties to record data like ID, name, location Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 20. Creating JavaScript Objects • Number of ways to create custom objects • Customer object • Properties to record data like ID, name, location • Some direct properties, others getter/setters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 21. Creating JavaScript Objects • Number of ways to create custom objects • Customer object • Properties to record data like ID, name, location • Some direct properties, others getter/setters • Override Object.toString Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 22. Creating JavaScript Objects • Number of ways to create custom objects • Customer object • Properties to record data like ID, name, location • Some direct properties, others getter/setters • Override Object.toString • Method to record sales Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 23. Using the Object Constructor Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 24. Using the Object Constructor • Use Object constructor with new keyword Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 25. Using the Object Constructor • Use Object constructor with new keyword • Creates a new object that inherits from Object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 26. Using the Object Constructor • Use Object constructor with new keyword • Creates a new object that inherits from Object • No arguments: new object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 27. Using the Object Constructor • Use Object constructor with new keyword • Creates a new object that inherits from Object • No arguments: new object • Primitive type argument: create new Number, Boolean, or String object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 28. Using an Object Literal Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 29. Using an Object Literal • Notable differences from Object constructor technique: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 30. Using an Object Literal • Notable differences from Object constructor technique: • Single statement Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 31. Using an Object Literal • Notable differences from Object constructor technique: • Single statement var customer = { }; Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 32. Using an Object Literal • Notable differences from Object constructor technique: • Single statement var customer = { }; • Adding properties Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 33. Using an Object Literal • Notable differences from Object constructor technique: • Single statement var customer = { }; • Adding properties • Defining getters and setters Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 34. Creating an Object Hierarchy with Prototypes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 35. Creating an Object Hierarchy with Prototypes • Can use customer as a prototype for other objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 36. Creating an Object Hierarchy with Prototypes • Can use customer as a prototype for other objects • New objects inherit properties of the base object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 37. Creating an Object Hierarchy with Prototypes • Can use customer as a prototype for other objects • New objects inherit properties of the base object • Called the prototype of the new objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 38. Creating an Object Hierarchy with Prototypes • Can use customer as a prototype for other objects • New objects inherit properties of the base object • Called the prototype of the new objects • Set of objects with same prototype is a class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 39. Object Identity Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 40. Object Identity • Can use the isPrototypeOf method Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 41. Object Identity • Can use the isPrototypeOf method • See whether one object has another as its prototype Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 42. Agenda Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 43. Agenda • Introduction to Object-Oriented JavaScript Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 44. Agenda • Introduction to Object-Oriented JavaScript • Creating JavaScript Objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 45. Agenda • Introduction to Object-Oriented JavaScript • Creating JavaScript Objects • Custom Object Constructors Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 46. Custom Object Constructors Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 47. Custom Object Constructors • Constructor is a function that initializes an object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 48. Custom Object Constructors • Constructor is a function that initializes an object • Used with the new keyword Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 49. Custom Object Constructors • Constructor is a function that initializes an object • Used with the new keyword • This actually creates the object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 50. Custom Object Constructors • Constructor is a function that initializes an object • Used with the new keyword • This actually creates the object • Constructor’s prototype object becomes prototype of new object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 51. Custom Object Constructors • Constructor is a function that initializes an object • Used with the new keyword • This actually creates the object • Constructor’s prototype object becomes prototype of new object • So all objects created with the constructor share prototypes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 52. Custom Object Constructors • Constructor is a function that initializes an object • Used with the new keyword • This actually creates the object • Constructor’s prototype object becomes prototype of new object • So all objects created with the constructor share prototypes • So all are members of the same class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 53. Creating a New Constructor Prototype Object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 54. Creating a New Constructor Prototype Object • Sample modified constructor’s default prototype object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 55. Creating a New Constructor Prototype Object • Sample modified constructor’s default prototype object • Alternatively, can create a whole new object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 56. Creating a New Constructor Prototype Object • Sample modified constructor’s default prototype object • Alternatively, can create a whole new object • Slightly cleaner code Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 57. Creating a New Constructor Prototype Object • Sample modified constructor’s default prototype object • Alternatively, can create a whole new object • Slightly cleaner code • Implement as single statement Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 58. Creating a New Constructor Prototype Object • Sample modified constructor’s default prototype object • Alternatively, can create a whole new object • Slightly cleaner code • Implement as single statement • Cleaner syntax Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 59. Dynamically Changing the Prototype of a Class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 60. Dynamically Changing the Prototype of a Class • Benefit of using a prototype is you can dynamically change it Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 61. Dynamically Changing the Prototype of a Class • Benefit of using a prototype is you can dynamically change it • Automatically changes all objects in the class Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 62. Dynamically Changing the Prototype of a Class • Benefit of using a prototype is you can dynamically change it • Automatically changes all objects in the class • Object inherits from prototype even when prototype subsequently changes Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 63. Dynamically Changing the Prototype of a Class • Benefit of using a prototype is you can dynamically change it • Automatically changes all objects in the class • Object inherits from prototype even when prototype subsequently changes • Can even modify prototypes of built-in objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 64. Object Identity with Constructors Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 65. Object Identity with Constructors • instanceof operator Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 66. Object Identity with Constructors • instanceof operator • Determine whether an object is an instance created by a constructor Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 67. Object Identity with Constructors • instanceof operator • Determine whether an object is an instance created by a constructor • Operands Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 68. Object Identity with Constructors • instanceof operator • Determine whether an object is an instance created by a constructor • Operands • Object to test Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 69. Object Identity with Constructors • instanceof operator • Determine whether an object is an instance created by a constructor • Operands • Object to test • Constructor object to test against Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 70. Object Identity with Constructors • instanceof operator • Determine whether an object is an instance created by a constructor • Operands • Object to test • Constructor object to test against • Pass anything as first operand, but second must be a function object Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 71. Object Identity with Constructors • instanceof operator • Determine whether an object is an instance created by a constructor • Operands • Object to test • Constructor object to test against • Pass anything as first operand, but second must be a function object • Reinforce the idea that constructors are the public identity of a class of objects Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 72. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 73. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

Editor's Notes

  • #2: \n
  • #3: \n
  • #4: \n
  • #5: \n
  • #6: \n
  • #7: \n
  • #8: \n
  • #9: \n
  • #10: \n
  • #11: \n
  • #12: \n
  • #13: \n
  • #14: \n
  • #15: \n
  • #16: \n
  • #17: \n
  • #18: \n
  • #19: \n
  • #20: \n
  • #21: \n
  • #22: \n
  • #23: \n
  • #24: \n
  • #25: DEMO – rest of section\n
  • #26: DEMO – rest of section\n
  • #27: DEMO – rest of section\n
  • #28: DEMO – rest of section\n
  • #29: DEMO – rest of section\n
  • #30: DEMO – rest of section\n
  • #31: DEMO – rest of section\n
  • #32: DEMO – rest of section\n
  • #33: DEMO – rest of section\n
  • #34: DEMO – rest of section\n
  • #35: DEMO – rest of section\n
  • #36: DEMO – rest of section\n
  • #37: DEMO – rest of section\n
  • #38: \n
  • #39: \n
  • #40: \n
  • #41: \n
  • #42: \n
  • #43: DEMO – Creating an Object Constructor section\n
  • #44: DEMO – Creating an Object Constructor section\n
  • #45: DEMO – Creating an Object Constructor section\n
  • #46: DEMO – Creating an Object Constructor section\n
  • #47: DEMO – Creating an Object Constructor section\n
  • #48: DEMO – Creating an Object Constructor section\n
  • #49: DEMO – rest of section\n
  • #50: DEMO – rest of section\n
  • #51: DEMO – rest of section\n
  • #52: DEMO – rest of section\n
  • #53: DEMO – rest of section\n
  • #54: DEMO – rest of section\n
  • #55: DEMO – rest of section\n
  • #56: DEMO – rest of section\n
  • #57: DEMO – rest of section\n
  • #58: DEMO – rest of section\n
  • #59: DEMO – rest of section\n
  • #60: DEMO – rest of section\n
  • #61: DEMO – rest of section\n
  • #62: DEMO – rest of section\n
  • #63: DEMO – rest of section\n
  • #64: DEMO – rest of section\n
  • #65: DEMO: rest of section\n