SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
ECMAScript 262-3
        @chenchengpro
Why ECMAScript?
History


• ECMA 262-3   1999 (current)
• ECMA 262-5   2009
SPEC ~
1. Scope
2. Conformance
3. References
4. Overview (      )
5. Notational Conventions (        )
6. Source Text (     )
7. Lexical Conventions (        )
8. Types (    )
9. Type Convertion (        )
10. Execution Contexts (          )
11. Expressions (        )
12. Statements (      )
13. Function Definition (        )
14. Program
15. Native ECMAScript Objects (ECMAScript   )
16. Errors (     )
1. Scope
2. Conformance
3. References
4. Overview (      )
5. Notational Conventions (        )
6. Source Text (     )
7. Lexical Conventions (        )
8. Types (    )
9. Type Convertion (        )
10. Execution Contexts (          )
11. Expressions (        )
12. Statements (      )
13. Function Definition (        )
14. Program
15. Native ECMAScript Objects (ECMAScript   )
16. Errors (     )
1. Scope
2. Conformance
3. References
4. Overview (      )
5. Notational Conventions (        )
6. Source Text (     )
7. Lexical Conventions (        )
8. Types (    )
9. Type Convertion (        )
10. Execution Contexts (          )
11. Expressions (        )
12. Statements (      )
13. Function Definition (        )
14. Program
15. Native ECMAScript Objects (ECMAScript   )
16. Errors (     )
Structure



 Expression, Statement, Function, ...

    Type, Type Convention
Definitions


• Host Object (       )
• Native Object (         )
• Build-in Object (           )
Definitions


 • Host Object (         )
 • Native Object (           )
 • Build-in Object (             )


test XMLHttpRequest, String, var obj = {}
Type
• Undefined
• Null
• Boolean           (Primitive)
• String
• Number
• Object
Object

ReadOnly

DontEnum

DontDelete

 Internal
[[Prototype]]
[[Class]]
[[Value]]
[[Get]]           (        )
[[Put]]           (        ,   )
[[CanPut]]        (        )
[[HasProperty]] (          )
[[Delete]]        (        )
[[DefaultValue]] (hint)                                 (   )
[[Construct]]     caller            (       )       new
[[Call]]          caller            (   )
[[hasInstance]]   (   )                         (   )
[[Scope]]
[[Match]]         (String, Index)
Type


• Reference
• List                (Internal)
• Completion
Reference
•
    • base
    • propertyName
•             delete operator

•
    • identifier evaluate
    • property accessor
Reference

var foo;
function bar() {}

//////////////////////

fooReference = {
    base: global,
    propertyName: ‘foo’
}
barReference = {
    base: global,
    propertyName: ‘bar’
}
Reference

function foo() {
    var bar;
}

//////////////////////

FooBarReference = {
    base: foo.__scope__, //
    propertyName: ‘bar’
}
Reference

var foo = {
    bar: ‘’
};

//////////////////////

FooBarReference = {
    base: foo,
    propertyName: ‘bar’
}
Reference

GetBase(V)                   base

GetPropertyName(V)

                               Reference   V
GetValue(V)
                             V   base

                         V     base
PutValue(V, W)
                     W
Type Convention

• ToPrimitive
• ToBoolean
• ToNumber, ToInteger
• ToString
• ToObject
ToPrimitive
ToPrimitive(Value, PreferredType)

  Undefined
    Null
   Boolean
   Number
    String

                  Object     [[DefaultValue]]
   Object
                           PreferredType
[[DefaultValue]]
[[DefaultValue]](hint)

•        hint    String     toString()
    valueOf()
•         hint   Number        valueOf(),
    toString()
•        hint                       Number
    (Date                 String)
ToBoolean

Undefined                  FALSE
  Null                    FALSE
Boolean
Number     +0, -0   NaN      false,           true

                     (length 0)       false
 String
                            true

 Object                   TRUE
ToNumber

Undefined                NaN
  Null                     0
Boolean      true      1   false     +0
Number
            StringNumericLiteral
 String
                                   NaN
                ToPrimate(V, Number)
 Object
                         ToNumber()
ToString

Undefined          “undefined”
  Null               “null”
Boolean        “true”         “false”

Number                  ...

 String
             ToPrimate(V, String)
 Object
                      ToString()
ToObject

Undefined          TypeError
  Null            TypeError
Boolean        new Boolean()
Number         new Number()
 String         new String()

 Object
'' == '0' // ?
0 == '' // ?
0 == '0' // ?

false == 'false' // ?
false == '0' // ?
false == undefined // ?
null == undefined // ?

' trn ' == 0 // ?
[] == 0 // ?

var obj = {};
obj.valueOf=function(){return 1};
obj.toString=function(){return 0;}
obj == 1; // ?
“equals operator”
11.9.1 The Equals Operator (== )
The production EqualityExpression : EqualityExpression ==
RelationalExpression is evaluated as follows:
1.     EqualityExpression
2.     GetValue(Result(1))
3.     RelationalExpression
4.     GetValue(Result(3))
5.     Result(4) == Result(2)          (     11.9.3)
6.     Result(5).
11.9.3 The Abstract Equality Comparison Algorithm
The comparison x == y, where x and y are values, produces true or
false. Such a comparison is performed as follows:
1.    Type(x)              Type(y)                       14
2.    Type(x)     Undefined,                  true
3.    Type(x)     Null,               true
4.    Type(x)             Number,                   11
5.    x    NaN,             false
6.    y    NaN,             false
7.    x    y                      ,      true
                                                              Type(x)
8.    x    +0         y     -0,          true                  Number
9.    x is -0     y        +0,          true
10.       false
11.   Type(x)     String,
          true               false
12.   Type(x)     Boolean,     x     y         true
        false        true                 false       Type(x)
13.   x       y
                                                        Number
          (       13.1.2)                false
14.    x    null     y       undefined,         true.
15.    x    undefined          y      null,     true.
16. Type(x)         Number          Type(y)     String,      x ==
ToNumber(y)
17. Type(x)         String        Type(y)     Number,        ToNumber
(x)== y
18.   Type(x)       Boolean,           ToNumber(x)== y
19.   Type(y)       Boolean,           x == ToNumber(y)


20. Type(x)      String           Number      Type(y)      Object,
x == ToPrimitive(y)
21. Type(x)      Object            Type(y)    String      Number,
ToPrimitive(x)== y
22. Return false.
'' == '0' // ?
0 == '' // ?
0 == '0' // ?

false == 'false' // ?
false == '0' // ?
false == undefined // ?
null == undefined // ?

' trn ' == 0 // ?
[] == 0 // ?

var obj = {};
obj.valueOf=function(){return 1};
obj.toString=function(){return 0;}
obj == 1; // ?
// [Object Object]
     alert(new function() {return "                           "});


     // “        ”
     alert(new function() {return new String(“
       ”);});


     // Why?




ref: http://www.planabc.net/2008/02/20/javascript_new_function/
“new operator”
11.2.2 The new Operator
The production NewExpression : new NewExpression is evaluated as
follows:
1.     NewExpression
2.     GetValue(Result(1))
3.   Type(Result(2))        Object,        TypeError
4.   Result(2)                         [[Construct]],   TypeError
5.     Result(2)       [[Construct]]
6.     Result(5)
13.2.2 [[Construct]]
When the [[Construct]] property for a Function object F is called,
the following steps are taken:
1.
2.     Result(1)       [[Class]]           "Object"
3.     F    prototype
4. Result(3)       object ,        Result(1)     [[Prototype]]
Result(3)
5.   Result(3)     object ,          Result(1)    [[Prototype]]
     Object    prototype              (     15.2.3.1)
6.     F    [[Call]]          Result(1)         this
[[Construct]]
7.   Type(Result(6))      Object               Result(6)
8.     Result(1)
• History
• Type
• Type Convention
• Examples
QA

Contenu connexe

Tendances

The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.5.2 book - Part 30 of 181The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.5.2 book - Part 30 of 181Mahmoud Samir Fayed
 
Peyton jones-2011-type classes
Peyton jones-2011-type classesPeyton jones-2011-type classes
Peyton jones-2011-type classesTakayuki Muranushi
 
Functor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadFunctor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadOliver Daff
 
oop presentation note
oop presentation note oop presentation note
oop presentation note Atit Patumvan
 
Understanding JavaScript
Understanding JavaScriptUnderstanding JavaScript
Understanding JavaScriptnodejsbcn
 
C# Language Overview Part I
C# Language Overview Part IC# Language Overview Part I
C# Language Overview Part IDoncho Minkov
 
Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)stasimus
 
FunScript 2013 (with speakers notes)
FunScript 2013 (with speakers notes)FunScript 2013 (with speakers notes)
FunScript 2013 (with speakers notes)Zach Bray
 
The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.5.4 book - Part 31 of 185The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.5.4 book - Part 31 of 185Mahmoud Samir Fayed
 
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Sanjeev_Knoldus
 
Stamps - a better way to object composition
Stamps - a better way to object compositionStamps - a better way to object composition
Stamps - a better way to object compositionVasyl Boroviak
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOJorge Vásquez
 
Core csharp and net quick reference
Core csharp and net quick referenceCore csharp and net quick reference
Core csharp and net quick referenceilesh raval
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202Mahmoud Samir Fayed
 

Tendances (19)

The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84
 
The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.5.2 book - Part 30 of 181The Ring programming language version 1.5.2 book - Part 30 of 181
The Ring programming language version 1.5.2 book - Part 30 of 181
 
Peyton jones-2011-type classes
Peyton jones-2011-type classesPeyton jones-2011-type classes
Peyton jones-2011-type classes
 
Functor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadFunctor, Apply, Applicative And Monad
Functor, Apply, Applicative And Monad
 
oop presentation note
oop presentation note oop presentation note
oop presentation note
 
Array notes
Array notesArray notes
Array notes
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 
Understanding JavaScript
Understanding JavaScriptUnderstanding JavaScript
Understanding JavaScript
 
Scalaz
ScalazScalaz
Scalaz
 
C# Language Overview Part I
C# Language Overview Part IC# Language Overview Part I
C# Language Overview Part I
 
Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)Introduction to Monads in Scala (1)
Introduction to Monads in Scala (1)
 
FunScript 2013 (with speakers notes)
FunScript 2013 (with speakers notes)FunScript 2013 (with speakers notes)
FunScript 2013 (with speakers notes)
 
The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.5.4 book - Part 31 of 185The Ring programming language version 1.5.4 book - Part 31 of 185
The Ring programming language version 1.5.4 book - Part 31 of 185
 
OOP v3
OOP v3OOP v3
OOP v3
 
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
 
Stamps - a better way to object composition
Stamps - a better way to object compositionStamps - a better way to object composition
Stamps - a better way to object composition
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
 
Core csharp and net quick reference
Core csharp and net quick referenceCore csharp and net quick reference
Core csharp and net quick reference
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202
 

Similaire à ECMA 入门

ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)Makoto Yamazaki
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
 
C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607Kevin Hazzard
 
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
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Paulo Morgado
 
Core c sharp and .net quick reference
Core c sharp and .net quick referenceCore c sharp and .net quick reference
Core c sharp and .net quick referenceArduino Aficionado
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed worldDebasish Ghosh
 
Build a compiler using C#, Irony and RunSharp.
Build a compiler using C#, Irony and RunSharp.Build a compiler using C#, Irony and RunSharp.
Build a compiler using C#, Irony and RunSharp.James Curran
 
Empathic Programming - How to write comprehensible code
Empathic Programming - How to write comprehensible codeEmpathic Programming - How to write comprehensible code
Empathic Programming - How to write comprehensible codeMario Gleichmann
 
An Overview of the Java Programming Language
An Overview of the Java Programming LanguageAn Overview of the Java Programming Language
An Overview of the Java Programming LanguageSalaam Kehinde
 
BabelJS - James Kyle at Modern Web UI
BabelJS - James Kyle at Modern Web UIBabelJS - James Kyle at Modern Web UI
BabelJS - James Kyle at Modern Web UImodernweb
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, SwiftYandex
 
Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016DesertJames
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Gostrikr .
 
Scala-对Java的修正和超越
Scala-对Java的修正和超越Scala-对Java的修正和超越
Scala-对Java的修正和超越Caoyuan Deng
 

Similaire à ECMA 入门 (20)

Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607
 
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
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
 
Core c sharp and .net quick reference
Core c sharp and .net quick referenceCore c sharp and .net quick reference
Core c sharp and .net quick reference
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed world
 
Build a compiler using C#, Irony and RunSharp.
Build a compiler using C#, Irony and RunSharp.Build a compiler using C#, Irony and RunSharp.
Build a compiler using C#, Irony and RunSharp.
 
Empathic Programming - How to write comprehensible code
Empathic Programming - How to write comprehensible codeEmpathic Programming - How to write comprehensible code
Empathic Programming - How to write comprehensible code
 
An Overview of the Java Programming Language
An Overview of the Java Programming LanguageAn Overview of the Java Programming Language
An Overview of the Java Programming Language
 
BabelJS - James Kyle at Modern Web UI
BabelJS - James Kyle at Modern Web UIBabelJS - James Kyle at Modern Web UI
BabelJS - James Kyle at Modern Web UI
 
Denis Lebedev, Swift
Denis  Lebedev, SwiftDenis  Lebedev, Swift
Denis Lebedev, Swift
 
Python crush course
Python crush coursePython crush course
Python crush course
 
Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016Kotlin Austin Droids April 14 2016
Kotlin Austin Droids April 14 2016
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Go
 
Json the-x-in-ajax1588
Json the-x-in-ajax1588Json the-x-in-ajax1588
Json the-x-in-ajax1588
 
Scala-对Java的修正和超越
Scala-对Java的修正和超越Scala-对Java的修正和超越
Scala-对Java的修正和超越
 
Kotlin Starter Pack
Kotlin Starter PackKotlin Starter Pack
Kotlin Starter Pack
 

Dernier

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Dernier (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

ECMA 入门

  • 1. ECMAScript 262-3 @chenchengpro
  • 3. History • ECMA 262-3 1999 (current) • ECMA 262-5 2009
  • 5. 1. Scope 2. Conformance 3. References 4. Overview ( ) 5. Notational Conventions ( ) 6. Source Text ( ) 7. Lexical Conventions ( ) 8. Types ( ) 9. Type Convertion ( ) 10. Execution Contexts ( ) 11. Expressions ( ) 12. Statements ( ) 13. Function Definition ( ) 14. Program 15. Native ECMAScript Objects (ECMAScript ) 16. Errors ( )
  • 6. 1. Scope 2. Conformance 3. References 4. Overview ( ) 5. Notational Conventions ( ) 6. Source Text ( ) 7. Lexical Conventions ( ) 8. Types ( ) 9. Type Convertion ( ) 10. Execution Contexts ( ) 11. Expressions ( ) 12. Statements ( ) 13. Function Definition ( ) 14. Program 15. Native ECMAScript Objects (ECMAScript ) 16. Errors ( )
  • 7. 1. Scope 2. Conformance 3. References 4. Overview ( ) 5. Notational Conventions ( ) 6. Source Text ( ) 7. Lexical Conventions ( ) 8. Types ( ) 9. Type Convertion ( ) 10. Execution Contexts ( ) 11. Expressions ( ) 12. Statements ( ) 13. Function Definition ( ) 14. Program 15. Native ECMAScript Objects (ECMAScript ) 16. Errors ( )
  • 8. Structure Expression, Statement, Function, ... Type, Type Convention
  • 9. Definitions • Host Object ( ) • Native Object ( ) • Build-in Object ( )
  • 10. Definitions • Host Object ( ) • Native Object ( ) • Build-in Object ( ) test XMLHttpRequest, String, var obj = {}
  • 11. Type • Undefined • Null • Boolean (Primitive) • String • Number • Object
  • 13. [[Prototype]] [[Class]] [[Value]] [[Get]] ( ) [[Put]] ( , ) [[CanPut]] ( ) [[HasProperty]] ( ) [[Delete]] ( ) [[DefaultValue]] (hint) ( ) [[Construct]] caller ( ) new [[Call]] caller ( ) [[hasInstance]] ( ) ( ) [[Scope]] [[Match]] (String, Index)
  • 14. Type • Reference • List (Internal) • Completion
  • 15. Reference • • base • propertyName • delete operator • • identifier evaluate • property accessor
  • 16. Reference var foo; function bar() {} ////////////////////// fooReference = { base: global, propertyName: ‘foo’ } barReference = { base: global, propertyName: ‘bar’ }
  • 17. Reference function foo() { var bar; } ////////////////////// FooBarReference = { base: foo.__scope__, // propertyName: ‘bar’ }
  • 18. Reference var foo = { bar: ‘’ }; ////////////////////// FooBarReference = { base: foo, propertyName: ‘bar’ }
  • 19. Reference GetBase(V) base GetPropertyName(V) Reference V GetValue(V) V base V base PutValue(V, W) W
  • 20. Type Convention • ToPrimitive • ToBoolean • ToNumber, ToInteger • ToString • ToObject
  • 21. ToPrimitive ToPrimitive(Value, PreferredType) Undefined Null Boolean Number String Object [[DefaultValue]] Object PreferredType
  • 22. [[DefaultValue]] [[DefaultValue]](hint) • hint String toString() valueOf() • hint Number valueOf(), toString() • hint Number (Date String)
  • 23. ToBoolean Undefined FALSE Null FALSE Boolean Number +0, -0 NaN false, true (length 0) false String true Object TRUE
  • 24. ToNumber Undefined NaN Null 0 Boolean true 1 false +0 Number StringNumericLiteral String NaN ToPrimate(V, Number) Object ToNumber()
  • 25. ToString Undefined “undefined” Null “null” Boolean “true” “false” Number ... String ToPrimate(V, String) Object ToString()
  • 26. ToObject Undefined TypeError Null TypeError Boolean new Boolean() Number new Number() String new String() Object
  • 27. '' == '0' // ? 0 == '' // ? 0 == '0' // ? false == 'false' // ? false == '0' // ? false == undefined // ? null == undefined // ? ' trn ' == 0 // ? [] == 0 // ? var obj = {}; obj.valueOf=function(){return 1}; obj.toString=function(){return 0;} obj == 1; // ?
  • 29. 11.9.1 The Equals Operator (== ) The production EqualityExpression : EqualityExpression == RelationalExpression is evaluated as follows: 1. EqualityExpression 2. GetValue(Result(1)) 3. RelationalExpression 4. GetValue(Result(3)) 5. Result(4) == Result(2) ( 11.9.3) 6. Result(5).
  • 30. 11.9.3 The Abstract Equality Comparison Algorithm The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows: 1. Type(x) Type(y) 14 2. Type(x) Undefined, true 3. Type(x) Null, true 4. Type(x) Number, 11 5. x NaN, false 6. y NaN, false 7. x y , true Type(x) 8. x +0 y -0, true Number 9. x is -0 y +0, true 10. false
  • 31. 11. Type(x) String, true false 12. Type(x) Boolean, x y true false true false Type(x) 13. x y Number ( 13.1.2) false
  • 32. 14. x null y undefined, true. 15. x undefined y null, true. 16. Type(x) Number Type(y) String, x == ToNumber(y) 17. Type(x) String Type(y) Number, ToNumber (x)== y 18. Type(x) Boolean, ToNumber(x)== y 19. Type(y) Boolean, x == ToNumber(y) 20. Type(x) String Number Type(y) Object, x == ToPrimitive(y) 21. Type(x) Object Type(y) String Number, ToPrimitive(x)== y 22. Return false.
  • 33. '' == '0' // ? 0 == '' // ? 0 == '0' // ? false == 'false' // ? false == '0' // ? false == undefined // ? null == undefined // ? ' trn ' == 0 // ? [] == 0 // ? var obj = {}; obj.valueOf=function(){return 1}; obj.toString=function(){return 0;} obj == 1; // ?
  • 34. // [Object Object] alert(new function() {return " "}); // “ ” alert(new function() {return new String(“ ”);}); // Why? ref: http://www.planabc.net/2008/02/20/javascript_new_function/
  • 36. 11.2.2 The new Operator The production NewExpression : new NewExpression is evaluated as follows: 1. NewExpression 2. GetValue(Result(1)) 3. Type(Result(2)) Object, TypeError 4. Result(2) [[Construct]], TypeError 5. Result(2) [[Construct]] 6. Result(5)
  • 37. 13.2.2 [[Construct]] When the [[Construct]] property for a Function object F is called, the following steps are taken: 1. 2. Result(1) [[Class]] "Object" 3. F prototype 4. Result(3) object , Result(1) [[Prototype]] Result(3) 5. Result(3) object , Result(1) [[Prototype]] Object prototype ( 15.2.3.1) 6. F [[Call]] Result(1) this [[Construct]] 7. Type(Result(6)) Object Result(6) 8. Result(1)
  • 38. • History • Type • Type Convention • Examples
  • 39. QA