SlideShare a Scribd company logo
1 of 25
Javascript - Core
object
• Javascript                    (   int)
         object

• function        object

• object拥         组properties              为
  null    prototype
object

• 义 var foo = { x:10, y: 20 };
• 读 foo.x OR foo[‘x’]
• 设 foo.x = 123 OR foo[‘x’] = 123
•          动态获 时
object

•   prototype          object


•     过__proto__        prototype


•   foo.__proto__ OR
    foo[‘__proto__’]
prototype chain
•            object 过__proto__
        实现继              property

• property    查   规则

 •            __proto__为null为

 •            property
prototype chain
•   var a = { x: 10,
       calculate: function(z) {
           return this.x + this.y + z
       }};
    var b = { y: 20, __proto__: a };
    var c = { y: 30, __proto__: a };

    b.calculate(30); //60
    c.calculate(40); //80
•        “对          ”调          时 this   对
prototype chain
•   object     认prototype
    Object.prototype

•       认为Object       Class
        object    Object
    instance

•   实际 Object          function
Constructor
•   function Foo(y) { this.y = y; }
    Foo.prototype.x = 10;
    Foo.prototype.calculate = function(z) {
       return this.x + this.y + z;
     }
    var b = new Foo(20);
    var c = new Foo(30);
    b.calculate(30); //60
    c.calculate(40); //80
•        这样        new Foo(20);

    •   var new_instance = { __proto__: Foo.prototype };
        Foo.call(new_instance, 20);
    •   Foo         function      Function    instance     __proto__
        Function.prototype
    •   call   Function.prototype      义                       this
Constructor
String literal
•   Instance           •   Constructor

•   {}                 •   Object

•   []                 •   Array

•   function() {}      •   Function

•   2                  •   Number

•   true               •   Boolean
Quiz
•   typeof Function ?
•   typeof Function.__proto__ ?
•   typeof Function.prototype ?
•   Function.__proto__ == Function.prototype ?
•   var Foo = function() {};
    typeof Foo
    typeof Foo.prototype ?
    typeof Foo.__proto__ ?
    typeof Foo.prototype.constructor ?
Execution Context
         Stack
• global, function, eval (EC)
• global EC
• function EC                   执
Execution Context


• EC   object
Variable Object
•   global EC VO

    •   var foo = 10;
        function bar() {};
•   function EC     VO

    •   function foo(x, y) {
           var z = 30;
           function bar() {}
        }
        foo(10, 20);
Scope Chain

•         prototype chain      查
    询“member variables” path

•       scope chain            查询“lexical
    variables” path
Scope Chain
• var x = 10;
  (function foo() {
     var y = 20;
     (function bar() {
        var z = 30;
        console.log(x + y + z);
     })();
  })();
__parent__

• __parent__        function   时

• global        义     __parent__    global
    VO
•    function     义    __parent__
    function VO
Closures
• var foo = function() {
        var x = 10;
    }
    foo();
•         foo()              VO    这
    VO                对           foo()执
    结             x
Closures
•   var foo = function() {
       var x = 10;
       return function() { console.log(x) };
    }
    var boo1 = foo();
    var boo2 = foo();
•   这    foo         执                function boo1 boo2
      VO       __parent__                foo VO       实
                  boo1      boo2           应 foo VO
Closures - Quiz

• var x = 10;
  function foo() { console.log(x, y); }
  (function (funArg) {
      var x = 20;
      var y = 30;
      funArg();
  })(foo);
Closures - Quiz
•   function baz() {
       var x = 1;
       return {
          foo: function foo() { return ++x; },
          bar: function bar() { return --x; }
       };
    }
    var closures = baz();

    closures.foo();
    closures.bar();
Closures
this

• function() this global
• obj.function() this obj
• function.call(obj) this obj
• new function() this           obj
Q &A
The End

More Related Content

What's hot

Functional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonadsFunctional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonadsAlexander Granin
 
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵Wanbok Choi
 
미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정SeungChul Kang
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架jeffz
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th StudyChris Ohk
 
Swift 0x0c 서브스크립트
Swift 0x0c 서브스크립트Swift 0x0c 서브스크립트
Swift 0x0c 서브스크립트Hyun Jin Moon
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris Ohk
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency명신 김
 
Burrowing through go! the book
Burrowing through go! the bookBurrowing through go! the book
Burrowing through go! the bookVishal Ghadge
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscexjeffz
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 
C++totural file
C++totural fileC++totural file
C++totural filehalaisumit
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)jeffz
 
Javascript OOP
Javascript OOPJavascript OOP
Javascript OOPMiao Siyu
 
Functors, applicatives, monads
Functors, applicatives, monadsFunctors, applicatives, monads
Functors, applicatives, monadsrkaippully
 
Exploring slides
Exploring slidesExploring slides
Exploring slidesakaptur
 

What's hot (20)

Functional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonadsFunctional "Life": parallel cellular automata and comonads
Functional "Life": parallel cellular automata and comonads
 
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
 
미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
Swift 0x0c 서브스크립트
Swift 0x0c 서브스크립트Swift 0x0c 서브스크립트
Swift 0x0c 서브스크립트
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency
 
Burrowing through go! the book
Burrowing through go! the bookBurrowing through go! the book
Burrowing through go! the book
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscex
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
C++totural file
C++totural fileC++totural file
C++totural file
 
JavaScript: enter the dragon
JavaScript: enter the dragonJavaScript: enter the dragon
JavaScript: enter the dragon
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
 
Javascript OOP
Javascript OOPJavascript OOP
Javascript OOP
 
Functors, applicatives, monads
Functors, applicatives, monadsFunctors, applicatives, monads
Functors, applicatives, monads
 
Exploring slides
Exploring slidesExploring slides
Exploring slides
 

Viewers also liked

the perception of style
the perception of stylethe perception of style
the perception of styleguest158075
 
Presentacio Amb Programari Lliure
Presentacio Amb Programari LliurePresentacio Amb Programari Lliure
Presentacio Amb Programari Lliureguest67f268
 
Quickstart
QuickstartQuickstart
Quickstarthyamada
 
Lic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensa
Lic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensaLic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensa
Lic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensaEmiliano Mejia R
 
The expectedness of style
The expectedness of styleThe expectedness of style
The expectedness of styleguest158075
 
Partition Manager 11 - Paragon Software
Partition Manager 11 - Paragon SoftwarePartition Manager 11 - Paragon Software
Partition Manager 11 - Paragon Softwareguestcf43641
 

Viewers also liked (7)

the perception of style
the perception of stylethe perception of style
the perception of style
 
Presentacio Amb Programari Lliure
Presentacio Amb Programari LliurePresentacio Amb Programari Lliure
Presentacio Amb Programari Lliure
 
Quickstart
QuickstartQuickstart
Quickstart
 
Lic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensa
Lic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensaLic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensa
Lic225 licitacion publica internacional 05 adq-ucpp-2007100-avisodeprensa
 
The expectedness of style
The expectedness of styleThe expectedness of style
The expectedness of style
 
Partition Manager 11 - Paragon Software
Partition Manager 11 - Paragon SoftwarePartition Manager 11 - Paragon Software
Partition Manager 11 - Paragon Software
 
Calendario 2016 con caratula
Calendario 2016 con caratulaCalendario 2016 con caratula
Calendario 2016 con caratula
 

Similar to Javascript - The core

Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreWeb Zhao
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almostQuinton Sheppard
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programmingjeffz
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」techtalkdwango
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScriptTakuya Fujimura
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changeshayato
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
JavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingJavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingChen Huang
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeManoj Kumar
 
ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)Makoto Yamazaki
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformationLars Marius Garshol
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Charles Nutter
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUIAdam Lu
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineRaimonds Simanovskis
 
Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02plutoone TestTwo
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile databaseChristian Melchior
 

Similar to Javascript - The core (20)

JavaScript Primer
JavaScript PrimerJavaScript Primer
JavaScript Primer
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
 
ECMA 入门
ECMA 入门ECMA 入门
ECMA 入门
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programming
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
サイ本 文
サイ本 文サイ本 文
サイ本 文
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
JavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote ScriptingJavaScript - Object-Oriented Programming & Remote Scripting
JavaScript - Object-Oriented Programming & Remote Scripting
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik Cube
 
ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
Ajaxworld
AjaxworldAjaxworld
Ajaxworld
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with Jasmine
 
Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02Prototype 120102020133-phpapp02
Prototype 120102020133-phpapp02
 
Realm: Building a mobile database
Realm: Building a mobile databaseRealm: Building a mobile database
Realm: Building a mobile database
 

Recently uploaded

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Recently uploaded (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Javascript - The core

  • 2. object • Javascript ( int) object • function object • object拥 组properties 为 null prototype
  • 3. object • 义 var foo = { x:10, y: 20 }; • 读 foo.x OR foo[‘x’] • 设 foo.x = 123 OR foo[‘x’] = 123 • 动态获 时
  • 4. object • prototype object • 过__proto__ prototype • foo.__proto__ OR foo[‘__proto__’]
  • 5. prototype chain • object 过__proto__ 实现继 property • property 查 规则 • __proto__为null为 • property
  • 6. prototype chain • var a = { x: 10, calculate: function(z) { return this.x + this.y + z }}; var b = { y: 20, __proto__: a }; var c = { y: 30, __proto__: a }; b.calculate(30); //60 c.calculate(40); //80 • “对 ”调 时 this 对
  • 7. prototype chain • object 认prototype Object.prototype • 认为Object Class object Object instance • 实际 Object function
  • 8. Constructor • function Foo(y) { this.y = y; } Foo.prototype.x = 10; Foo.prototype.calculate = function(z) { return this.x + this.y + z; } var b = new Foo(20); var c = new Foo(30); b.calculate(30); //60 c.calculate(40); //80 • 这样 new Foo(20); • var new_instance = { __proto__: Foo.prototype }; Foo.call(new_instance, 20); • Foo function Function instance __proto__ Function.prototype • call Function.prototype 义 this
  • 10. String literal • Instance • Constructor • {} • Object • [] • Array • function() {} • Function • 2 • Number • true • Boolean
  • 11. Quiz • typeof Function ? • typeof Function.__proto__ ? • typeof Function.prototype ? • Function.__proto__ == Function.prototype ? • var Foo = function() {}; typeof Foo typeof Foo.prototype ? typeof Foo.__proto__ ? typeof Foo.prototype.constructor ?
  • 12. Execution Context Stack • global, function, eval (EC) • global EC • function EC 执
  • 14. Variable Object • global EC VO • var foo = 10; function bar() {}; • function EC VO • function foo(x, y) { var z = 30; function bar() {} } foo(10, 20);
  • 15. Scope Chain • prototype chain 查 询“member variables” path • scope chain 查询“lexical variables” path
  • 16. Scope Chain • var x = 10; (function foo() { var y = 20; (function bar() { var z = 30; console.log(x + y + z); })(); })();
  • 17. __parent__ • __parent__ function 时 • global 义 __parent__ global VO • function 义 __parent__ function VO
  • 18. Closures • var foo = function() { var x = 10; } foo(); • foo() VO 这 VO 对 foo()执 结 x
  • 19. Closures • var foo = function() { var x = 10; return function() { console.log(x) }; } var boo1 = foo(); var boo2 = foo(); • 这 foo 执 function boo1 boo2 VO __parent__ foo VO 实 boo1 boo2 应 foo VO
  • 20. Closures - Quiz • var x = 10; function foo() { console.log(x, y); } (function (funArg) { var x = 20; var y = 30; funArg(); })(foo);
  • 21. Closures - Quiz • function baz() { var x = 1; return { foo: function foo() { return ++x; }, bar: function bar() { return --x; } }; } var closures = baz(); closures.foo(); closures.bar();
  • 23. this • function() this global • obj.function() this obj • function.call(obj) this obj • new function() this obj
  • 24. Q &A

Editor's Notes

  1. \n
  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. \n