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

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 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
 
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
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Dernier (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

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