SlideShare a Scribd company logo
1 of 13
Download to read offline
JavaScript Object Model

      James S. Hsieh
JavaScript build-in datatype

Primitive
    Number (float), String, Boolean, undefined, null

And Object
    Array, Function, RegExp, Date .... 
Object 
● JavaScript Object is a hash of key and value.
● How to create a Object? {}
● How to assemble a Object?
  var myObject = {
     "!@. #%": "what is that?",
     value: 1,
     abc: { key: 2 },
     fun: function() {
       return myObject;
     }
  };

  myObject.value;       //   1
  myObject.abc;         //   { key: 2 }
  myObject.!@. #%       //   SyntaxError: Unexpected string
  myObject["!@. #%"];   //   "what is that?"
  myObject.fun;         //   function
  myObject.fun();       //   call function
  myObject.xxx;         //   undefined
Array
● JavaScript Array is a object
● How to create a Array? []
● How to assemble a Array?
 var myArray = [1, "x", function() { return myArray; }];

 myArray[2];       // return element of array
 myArray.length;      // 3
 myArray.abc = "xxx"; // add member to array
 typeof myArray;      // "object"
Function
● JavaScript Function is a object.
● How to create a Function function() {}
● Function object is a invokable.
● All Functions return a value.
● Default is undefined, it can return any object.

● this is execution context.
    ○ If function object is invoked by a.fun();
      execution context of fun is a (this == a)
    ○ If function object is invoked by fun();
      execution context of fun is DOMWindow
    ○ If function object is invoked by new fun();
      .....
Constructor - assemble an object
     ● when invoked with new, functions return an object known
       as this. You can return other object to replace this.
     ● You have a chance of modifying this before it's returned.

        var Engineer = function(name) {
            this.name = name;
            this.favoriteLanguage = "JavaScript";
            this.program = function() {
                return this.createBug();
            };
            this.createBug = function() {
                    /* .... */                           
            };
        };

          var james = new Engineer("James S. Hsieh");        // prototype an object
          james.name;                                                        // "James S. Hsieh"
          james.program();                                                 // call function
          james.constructor == Engineer;                            // true
Constructor - Questions
        var Engineer = function(name) {
            this.name = name;
            this.favoriteLanguage = "JavaScript";
            this.program = function() {
                return this.createBug();
            };
            this.createBug = function() {
                    /* .... */                           
            };
        };

        var james = new Engineer("James");
        var chacha = new Engineer("Chacha");

        chacha.program = // overwrite
            function() { /* new function */ };

        chacha.program();   // what?
        james.program();     // what?
        james.hasOwnProperty("program"); // true
Prototype
A prototype is an early sample or model built to test
a concept or process or to act as a thing to be
replicated or learned from.

   var Engineer = function(name) {
       this.name = name;
       this.favoriteLanguage = "JavaScript";
   };

     Engineer.prototype.program = function() {
         return this.createBug();
     };
     Engineer.prototype.createBug = function() {
         /* .... */                           
     };

   var james = new Engineer("James");
  
    ● All objects of Engineer refer one prototype
    ● object.__proto__ === Engineer.prototype
Prototype - Questions
   var Engineer = function(name) {
       this.name = name;
       this.favoriteLanguage = "JavaScript";
   };

     Engineer.prototype.program = function() {
         return this.createBug();
     };
     Engineer.prototype.createBug = function() {
         /* .... */                           
     };
     
    var james = new Engineer("James");
    var chacha = new Engineer("Chacha");

  Engineer.prototype.program = // overwrite
    function() { /* new function */ }; 

  chacha.program();   // what?
  james.program();     // what?
  james.hasOwnProperty("program"); // false
Prototype chain
Prototype can be a chain, and JavaScript
has a build-in mechanism to resolve
property by this chain. It and C++
inheritance are similar.

Employee <- Engineer

     var james = new Engineer();
     james.A();
     james.B();
     james.C();

   var someOne = new Employee();
   someOne.A();
   someOne.B();
Prototype chain
   var Employee = function() {
        this.aaa = "hellow"; 
   };
   Employee.prototype.A = function() { alert("1"); }; 
   Employee.prototype.B = function() { alert("2"); };  

   var Engineer = function() {         
   };

1. Engineer.prototype = Employee.prototype;
    Engineer.prototype.constructor = Engineer;

2. Engineer.prototype = new Employee();
    Engineer.prototype.constructor = Engineer;

3. var tmp = function() {};
    tmp.prototype = Employee.prototype;
    Engineer.prototype = new tmp();
    Engineer.prototype.constructor = Engineer;

   Engineer.prototype.B = function() { alert("3"); };   
   Engineer.prototype.C = function() { alert("4"); }; 
MooTools framework
MooTools is a compact, modular, Object-Oriented JavaScript framework designed for the
intermediate to advanced JavaScript developer. It allows you to write powerful, flexible,
and cross-browser code with its elegant, well documented, and coherent API.

http://mootools.net/docs/core/Class/Class
http://mootools.net/docs/core/Class/Class.Extras

var Animal = new Class({
  initialize: function(name){ 
    this.name = name;
  } 
}); 

var Cat = new Class({
  Extends: Animal, 
  talk: function(){ 
    return 'Meow!'; 
  } 
});

var james = new Animal('james');
var missy = new Cat('Missy');
Reference

Book: JavaScript Patterns

MooTools: http://mootools.net/

Advanced JavaScript: Closures, Prototypes and Inheritance:
http://www.slideshare.net/Sampetruda/advanced-javascript-
closures-prototypes-and-inheritance?
src=related_normal&rel=1188958

More Related Content

What's hot

Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScriptNascenia IT
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptzand3rs
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScriptFu Cheng
 
AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.Yan Yankowski
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testingVikas Thange
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS ArchitectureEyal Vardi
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptVisual Engineering
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSNicolas Embleton
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJWORKS powered by Ordina
 
AngularJS Services
AngularJS ServicesAngularJS Services
AngularJS ServicesEyal Vardi
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptForziatech
 
Angular 2 Architecture
Angular 2 ArchitectureAngular 2 Architecture
Angular 2 ArchitectureEyal Vardi
 
AngularJS Animations
AngularJS AnimationsAngularJS Animations
AngularJS AnimationsEyal Vardi
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile ProcessEyal Vardi
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0Eyal Vardi
 

What's hot (20)

Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.AngularJs $provide API internals & circular dependency problem.
AngularJs $provide API internals & circular dependency problem.
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
 
Javascript
JavascriptJavascript
Javascript
 
AngularJS Architecture
AngularJS ArchitectureAngularJS Architecture
AngularJS Architecture
 
AngularJs
AngularJsAngularJs
AngularJs
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
GDayX - Advanced Angular.JS
GDayX - Advanced Angular.JSGDayX - Advanced Angular.JS
GDayX - Advanced Angular.JS
 
JavaScript Inheritance
JavaScript InheritanceJavaScript Inheritance
JavaScript Inheritance
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
 
AngularJS Services
AngularJS ServicesAngularJS Services
AngularJS Services
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
Angular 2 Architecture
Angular 2 ArchitectureAngular 2 Architecture
Angular 2 Architecture
 
AngularJS Animations
AngularJS AnimationsAngularJS Animations
AngularJS Animations
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 
Anonymous functions in JavaScript
Anonymous functions in JavaScriptAnonymous functions in JavaScript
Anonymous functions in JavaScript
 
Template syntax in Angular 2.0
Template syntax in Angular 2.0Template syntax in Angular 2.0
Template syntax in Angular 2.0
 

Viewers also liked

2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...
2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...
2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...James Hsieh
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharingJames Hsieh
 
Slideshare 基本操作教學
Slideshare 基本操作教學Slideshare 基本操作教學
Slideshare 基本操作教學Ying Huang
 
100個網站規劃必備的知識 整合:使用者體驗設計分享
100個網站規劃必備的知識 整合:使用者體驗設計分享100個網站規劃必備的知識 整合:使用者體驗設計分享
100個網站規劃必備的知識 整合:使用者體驗設計分享William Lin
 
認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your Team
認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your Team認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your Team
認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your TeamIvan Wei
 
User Interview Techniques
User Interview TechniquesUser Interview Techniques
User Interview TechniquesLiz Danzico
 
從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術Will Huang
 
產品設計的0到1,與1到1億
產品設計的0到1,與1到1億產品設計的0到1,與1到1億
產品設計的0到1,與1到1億Ivan Wei
 
改變行為的設計:一些理論
改變行為的設計:一些理論改變行為的設計:一些理論
改變行為的設計:一些理論Vivian Chen
 
用戶體驗設計,從需求到產品落地
用戶體驗設計,從需求到產品落地用戶體驗設計,從需求到產品落地
用戶體驗設計,從需求到產品落地Ivan Wei
 
阿里巴巴只做沒說的秘密
阿里巴巴只做沒說的秘密阿里巴巴只做沒說的秘密
阿里巴巴只做沒說的秘密Max Chang
 
Hooked Model
Hooked ModelHooked Model
Hooked ModelNir Eyal
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017Drift
 

Viewers also liked (15)

2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...
2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...
2008 07 31 Understanding and Using COM Threading Model - An Inconvenient Trut...
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
 
Slideshare 基本操作教學
Slideshare 基本操作教學Slideshare 基本操作教學
Slideshare 基本操作教學
 
100個網站規劃必備的知識 整合:使用者體驗設計分享
100個網站規劃必備的知識 整合:使用者體驗設計分享100個網站規劃必備的知識 整合:使用者體驗設計分享
100個網站規劃必備的知識 整合:使用者體驗設計分享
 
認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your Team
認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your Team認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your Team
認識用戶體驗設計的價值與招募要點 - Recruit UX Talents For Your Team
 
User Interview Techniques
User Interview TechniquesUser Interview Techniques
User Interview Techniques
 
從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術從開發人員角度十分鐘理解區塊鏈技術
從開發人員角度十分鐘理解區塊鏈技術
 
Js ppt
Js pptJs ppt
Js ppt
 
產品設計的0到1,與1到1億
產品設計的0到1,與1到1億產品設計的0到1,與1到1億
產品設計的0到1,與1到1億
 
改變行為的設計:一些理論
改變行為的設計:一些理論改變行為的設計:一些理論
改變行為的設計:一些理論
 
用戶體驗設計,從需求到產品落地
用戶體驗設計,從需求到產品落地用戶體驗設計,從需求到產品落地
用戶體驗設計,從需求到產品落地
 
阿里巴巴只做沒說的秘密
阿里巴巴只做沒說的秘密阿里巴巴只做沒說的秘密
阿里巴巴只做沒說的秘密
 
Hooked Model
Hooked ModelHooked Model
Hooked Model
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
3 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 20173 Things Every Sales Team Needs to Be Thinking About in 2017
3 Things Every Sales Team Needs to Be Thinking About in 2017
 

Similar to Java script object model

Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oopLearningTech
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Alberto Naranjo
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript Dhananjay Kumar
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design PatternsZohar Arad
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesSiarhei Barysiuk
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to JavascriptAnjan Banda
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScriptJulie Iskander
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Librariesjeresig
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascriptguest4d57e6
 
Engineering JavaScript
Engineering JavaScriptEngineering JavaScript
Engineering JavaScriptJim Purbrick
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp DeveloperSarvesh Kushwaha
 
Journey of a C# developer into Javascript
Journey of a C# developer into JavascriptJourney of a C# developer into Javascript
Journey of a C# developer into JavascriptMassimo Franciosa
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 

Similar to Java script object model (20)

Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.
 
Functions and Objects in JavaScript
Functions and Objects in JavaScript Functions and Objects in JavaScript
Functions and Objects in JavaScript
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Let's JavaScript
Let's JavaScriptLet's JavaScript
Let's JavaScript
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Java script for web developer
Java script for web developerJava script for web developer
Java script for web developer
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascript
 
Engineering JavaScript
Engineering JavaScriptEngineering JavaScript
Engineering JavaScript
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
Journey of a C# developer into Javascript
Journey of a C# developer into JavascriptJourney of a C# developer into Javascript
Journey of a C# developer into Javascript
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 

Recently uploaded

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Java script object model

  • 1. JavaScript Object Model James S. Hsieh
  • 2. JavaScript build-in datatype Primitive     Number (float), String, Boolean, undefined, null And Object     Array, Function, RegExp, Date .... 
  • 3. Object  ● JavaScript Object is a hash of key and value. ● How to create a Object? {} ● How to assemble a Object? var myObject = { "!@. #%": "what is that?", value: 1, abc: { key: 2 }, fun: function() { return myObject; } }; myObject.value; // 1 myObject.abc; // { key: 2 } myObject.!@. #% // SyntaxError: Unexpected string myObject["!@. #%"]; // "what is that?" myObject.fun; // function myObject.fun(); // call function myObject.xxx; // undefined
  • 4. Array ● JavaScript Array is a object ● How to create a Array? [] ● How to assemble a Array? var myArray = [1, "x", function() { return myArray; }]; myArray[2]; // return element of array myArray.length; // 3 myArray.abc = "xxx"; // add member to array typeof myArray; // "object"
  • 5. Function ● JavaScript Function is a object. ● How to create a Function function() {} ● Function object is a invokable. ● All Functions return a value. ● Default is undefined, it can return any object. ● this is execution context. ○ If function object is invoked by a.fun(); execution context of fun is a (this == a) ○ If function object is invoked by fun(); execution context of fun is DOMWindow ○ If function object is invoked by new fun(); .....
  • 6. Constructor - assemble an object ● when invoked with new, functions return an object known as this. You can return other object to replace this. ● You have a chance of modifying this before it's returned.         var Engineer = function(name) {             this.name = name;             this.favoriteLanguage = "JavaScript";             this.program = function() {                 return this.createBug();             };             this.createBug = function() {                     /* .... */                                        };         };         var james = new Engineer("James S. Hsieh");        // prototype an object         james.name;                                                        // "James S. Hsieh"         james.program();                                                 // call function         james.constructor == Engineer;                            // true
  • 7. Constructor - Questions         var Engineer = function(name) {             this.name = name;             this.favoriteLanguage = "JavaScript";             this.program = function() {                 return this.createBug();             };             this.createBug = function() {                     /* .... */                                        };         };         var james = new Engineer("James");         var chacha = new Engineer("Chacha");         chacha.program = // overwrite             function() { /* new function */ };         chacha.program();   // what?         james.program();     // what?         james.hasOwnProperty("program"); // true
  • 8. Prototype A prototype is an early sample or model built to test a concept or process or to act as a thing to be replicated or learned from.    var Engineer = function(name) {        this.name = name;        this.favoriteLanguage = "JavaScript";    };    Engineer.prototype.program = function() {        return this.createBug();    };    Engineer.prototype.createBug = function() {        /* .... */                               };    var james = new Engineer("James");    ● All objects of Engineer refer one prototype ● object.__proto__ === Engineer.prototype
  • 9. Prototype - Questions    var Engineer = function(name) {        this.name = name;        this.favoriteLanguage = "JavaScript";    };    Engineer.prototype.program = function() {        return this.createBug();    };    Engineer.prototype.createBug = function() {        /* .... */                               };       var james = new Engineer("James");   var chacha = new Engineer("Chacha");   Engineer.prototype.program = // overwrite     function() { /* new function */ };    chacha.program();   // what?   james.program();     // what?   james.hasOwnProperty("program"); // false
  • 10. Prototype chain Prototype can be a chain, and JavaScript has a build-in mechanism to resolve property by this chain. It and C++ inheritance are similar. Employee <- Engineer    var james = new Engineer();    james.A();    james.B();    james.C();    var someOne = new Employee();    someOne.A();    someOne.B();
  • 11. Prototype chain    var Employee = function() {         this.aaa = "hellow";     };    Employee.prototype.A = function() { alert("1"); };     Employee.prototype.B = function() { alert("2"); };      var Engineer = function() {             }; 1. Engineer.prototype = Employee.prototype;     Engineer.prototype.constructor = Engineer; 2. Engineer.prototype = new Employee();     Engineer.prototype.constructor = Engineer; 3. var tmp = function() {};     tmp.prototype = Employee.prototype;     Engineer.prototype = new tmp();     Engineer.prototype.constructor = Engineer;    Engineer.prototype.B = function() { alert("3"); };       Engineer.prototype.C = function() { alert("4"); }; 
  • 12. MooTools framework MooTools is a compact, modular, Object-Oriented JavaScript framework designed for the intermediate to advanced JavaScript developer. It allows you to write powerful, flexible, and cross-browser code with its elegant, well documented, and coherent API. http://mootools.net/docs/core/Class/Class http://mootools.net/docs/core/Class/Class.Extras var Animal = new Class({   initialize: function(name){      this.name = name;   }  });  var Cat = new Class({   Extends: Animal,    talk: function(){      return 'Meow!';    }  }); var james = new Animal('james'); var missy = new Cat('Missy');
  • 13. Reference Book: JavaScript Patterns MooTools: http://mootools.net/ Advanced JavaScript: Closures, Prototypes and Inheritance: http://www.slideshare.net/Sampetruda/advanced-javascript- closures-prototypes-and-inheritance? src=related_normal&rel=1188958