SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
Paren-free
                              Brendan Eich
                          brendan@mozilla.org




Saturday, June 11, 2011
Motivation




Saturday, June 11, 2011
History




Saturday, June 11, 2011
History

                     •    JS derives from Java from C++ from C (via early C and B), from
                          BCPL. BCPL had paren-free if, etc., heads disambiguated via the
                          do reserved word to separate an expression consequent, avoiding
                          ambiguity.




Saturday, June 11, 2011
History

                     •    JS derives from Java from C++ from C (via early C and B), from
                          BCPL. BCPL had paren-free if, etc., heads disambiguated via the
                          do reserved word to separate an expression consequent, avoiding
                          ambiguity.

                     •    Many JS style guides favor mandatory bracing of if consequents
                          and other sub-statement bodies, in order to avoid dangling else bugs.




Saturday, June 11, 2011
History

                     •    JS derives from Java from C++ from C (via early C and B), from
                          BCPL. BCPL had paren-free if, etc., heads disambiguated via the
                          do reserved word to separate an expression consequent, avoiding
                          ambiguity.

                     •    Many JS style guides favor mandatory bracing of if consequents
                          and other sub-statement bodies, in order to avoid dangling else bugs.

                     •    By comparison to nearby programming languages, JS syntax is
                          “shifty” to write and noisy to read. Can we do better?




Saturday, June 11, 2011
Examples
                if year > 2010 {
                    syntax++
                }

                for let i of iter {                 // i is fresh on each iteration
                    frob(i)
                }

                while lo <= hi {
                    let mid = (lo + hi) / 2

                          // binary search body goes here
                }

                ... return [i * i for i in range(n)]        // array comprehension




Saturday, June 11, 2011
Examples, cont.
                     •    Must support:        •   but not mandate:

                           if x < y {               if x < y {


                           } else if x < z {        } else {

                           } else if x < w {            if x < z {

                           } else {                     } else {

                           }                                if x < w {

                                                            } else {

                                                            }
                                                        }
                                                    }




Saturday, June 11, 2011
Syntax
                     •    IfStatement :

                            if   Expression SubStatement else SubStatement
                            if   Expression SubStatement
                            if   ( Expression ) OtherStatement else Statement
                            if   ( Expression ) OtherStatement

                     •    etc. for while, do-while, for, switch, catch

                     •    SubStatement :

                            Block
                            KeywordStatement




Saturday, June 11, 2011
Syntax, cont.
                     •    KeywordStatement :    •   Statement :

                           IfStatement               Block
                           IterationStatement        KeywordStatement
                           ContinueStatement         OtherStatement
                           BreakStatement
                           ReturnStatement
                           SwitchStatement
                                                •   OtherStatement :

                           ThrowStatement
                           TryStatement              EmptyStatement
                           DebuggerStatement         ExpressionStatement
                                                     LabelledStatement
                                                     VariableStatement




Saturday, June 11, 2011
Compatibility




Saturday, June 11, 2011
Compatibility
                     •    if, while, do-while, and switch statements, where the
                          head syntax is Expression, which may be over-parenthesized.




Saturday, June 11, 2011
Compatibility
                     •    if, while, do-while, and switch statements, where the
                          head syntax is Expression, which may be over-parenthesized.

                     •    try, catch, finally must be braced as in ES3 and ES5.




Saturday, June 11, 2011
Compatibility
                     •    if, while, do-while, and switch statements, where the
                          head syntax is Expression, which may be over-parenthesized.

                     •    try, catch, finally must be braced as in ES3 and ES5.

                     •    catch heads may be parenthesized or unparenthesized.




Saturday, June 11, 2011
Compatibility
                     •    if, while, do-while, and switch statements, where the
                          head syntax is Expression, which may be over-parenthesized.

                     •    try, catch, finally must be braced as in ES3 and ES5.

                     •    catch heads may be parenthesized or unparenthesized.

                     •    for heads may be parenthesized or unparenthesized.




Saturday, June 11, 2011
Compatibility
                     •    if, while, do-while, and switch statements, where the
                          head syntax is Expression, which may be over-parenthesized.

                     •    try, catch, finally must be braced as in ES3 and ES5.

                     •    catch heads may be parenthesized or unparenthesized.

                     •    for heads may be parenthesized or unparenthesized.

                     •    for-in/of heads may be parenthesized or unparenthesized.




Saturday, June 11, 2011
Compatibility
                     •    if, while, do-while, and switch statements, where the
                          head syntax is Expression, which may be over-parenthesized.

                     •    try, catch, finally must be braced as in ES3 and ES5.

                     •    catch heads may be parenthesized or unparenthesized.

                     •    for heads may be parenthesized or unparenthesized.

                     •    for-in/of heads may be parenthesized or unparenthesized.

                     •    for-of loop, comprehension, and generator expression new
                          semantics (next slide).




Saturday, June 11, 2011
for-in & for-of




Saturday, June 11, 2011
for-in & for-of
                     •    for k in o iterates over keys not values for all objects o.




Saturday, June 11, 2011
for-in & for-of
                     •    for k in o iterates over keys not values for all objects o.

                     •    for k of {p:1, q:2} iterates over 1, 2.




Saturday, June 11, 2011
for-in & for-of
                     •    for k in o iterates over keys not values for all objects o.

                     •    for k of {p:1, q:2} iterates over 1, 2.

                     •    for v of [3, 4, 5] iterates over 3, 4, 5.




Saturday, June 11, 2011
for-in & for-of
                     •    for k in o iterates over keys not values for all objects o.

                     •    for k of {p:1, q:2} iterates over 1, 2.

                     •    for v of [3, 4, 5] iterates over 3, 4, 5.

                     •    for k of keys(o) iterates over keys in o.




Saturday, June 11, 2011
for-in & for-of
                     •    for k in o iterates over keys not values for all objects o.

                     •    for k of {p:1, q:2} iterates over 1, 2.

                     •    for v of [3, 4, 5] iterates over 3, 4, 5.

                     •    for k of keys(o) iterates over keys in o.

                     •    for v of values(o) iterates over values in o.




Saturday, June 11, 2011
for-in & for-of
                     •    for k in o iterates over keys not values for all objects o.

                     •    for k of {p:1, q:2} iterates over 1, 2.

                     •    for v of [3, 4, 5] iterates over 3, 4, 5.

                     •    for k of keys(o) iterates over keys in o.

                     •    for v of values(o) iterates over values in o.

                     •    for [k, v] of items(o) iterates over key/value pairs.




Saturday, June 11, 2011
for-in & for-of
                     •    for k in o iterates over keys not values for all objects o.

                     •    for k of {p:1, q:2} iterates over 1, 2.

                     •    for v of [3, 4, 5] iterates over 3, 4, 5.

                     •    for k of keys(o) iterates over keys in o.

                     •    for v of values(o) iterates over values in o.

                     •    for [k, v] of items(o) iterates over key/value pairs.

                     •    for x of proxy iterates using the handler iterate trap.
                          (http://wiki.ecmascript.org/doku.php?id=harmony:iterators)



Saturday, June 11, 2011

Más contenido relacionado

Destacado

Mozilla's NodeConf talk
Mozilla's NodeConf talkMozilla's NodeConf talk
Mozilla's NodeConf talkBrendan Eich
 
Mozilla Research Party Talk
Mozilla Research Party TalkMozilla Research Party Talk
Mozilla Research Party TalkBrendan Eich
 
Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016Brendan Eich
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptBrendan Eich
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Brendan Eich
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressBrendan Eich
 
The Same-Origin Saga
The Same-Origin SagaThe Same-Origin Saga
The Same-Origin SagaBrendan Eich
 

Destacado (13)

Capitol js
Capitol jsCapitol js
Capitol js
 
Mozilla's NodeConf talk
Mozilla's NodeConf talkMozilla's NodeConf talk
Mozilla's NodeConf talk
 
Taysom seminar
Taysom seminarTaysom seminar
Taysom seminar
 
Mozilla Research Party Talk
Mozilla Research Party TalkMozilla Research Party Talk
Mozilla Research Party Talk
 
dotJS 2015
dotJS 2015dotJS 2015
dotJS 2015
 
Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScript
 
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progress
 
Splash
SplashSplash
Splash
 
Txjs talk
Txjs talkTxjs talk
Txjs talk
 
The Same-Origin Saga
The Same-Origin SagaThe Same-Origin Saga
The Same-Origin Saga
 
Int64
Int64Int64
Int64
 

Último

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
 
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
 
[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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
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
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Último (20)

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...
 
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
 
[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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
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
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Paren free

  • 1. Paren-free Brendan Eich brendan@mozilla.org Saturday, June 11, 2011
  • 4. History • JS derives from Java from C++ from C (via early C and B), from BCPL. BCPL had paren-free if, etc., heads disambiguated via the do reserved word to separate an expression consequent, avoiding ambiguity. Saturday, June 11, 2011
  • 5. History • JS derives from Java from C++ from C (via early C and B), from BCPL. BCPL had paren-free if, etc., heads disambiguated via the do reserved word to separate an expression consequent, avoiding ambiguity. • Many JS style guides favor mandatory bracing of if consequents and other sub-statement bodies, in order to avoid dangling else bugs. Saturday, June 11, 2011
  • 6. History • JS derives from Java from C++ from C (via early C and B), from BCPL. BCPL had paren-free if, etc., heads disambiguated via the do reserved word to separate an expression consequent, avoiding ambiguity. • Many JS style guides favor mandatory bracing of if consequents and other sub-statement bodies, in order to avoid dangling else bugs. • By comparison to nearby programming languages, JS syntax is “shifty” to write and noisy to read. Can we do better? Saturday, June 11, 2011
  • 7. Examples if year > 2010 { syntax++ } for let i of iter { // i is fresh on each iteration frob(i) } while lo <= hi { let mid = (lo + hi) / 2 // binary search body goes here } ... return [i * i for i in range(n)] // array comprehension Saturday, June 11, 2011
  • 8. Examples, cont. • Must support: • but not mandate: if x < y { if x < y { } else if x < z { } else { } else if x < w { if x < z { } else { } else { } if x < w { } else { } } } Saturday, June 11, 2011
  • 9. Syntax • IfStatement : if Expression SubStatement else SubStatement if Expression SubStatement if ( Expression ) OtherStatement else Statement if ( Expression ) OtherStatement • etc. for while, do-while, for, switch, catch • SubStatement : Block KeywordStatement Saturday, June 11, 2011
  • 10. Syntax, cont. • KeywordStatement : • Statement : IfStatement Block IterationStatement KeywordStatement ContinueStatement OtherStatement BreakStatement ReturnStatement SwitchStatement • OtherStatement : ThrowStatement TryStatement EmptyStatement DebuggerStatement ExpressionStatement LabelledStatement VariableStatement Saturday, June 11, 2011
  • 12. Compatibility • if, while, do-while, and switch statements, where the head syntax is Expression, which may be over-parenthesized. Saturday, June 11, 2011
  • 13. Compatibility • if, while, do-while, and switch statements, where the head syntax is Expression, which may be over-parenthesized. • try, catch, finally must be braced as in ES3 and ES5. Saturday, June 11, 2011
  • 14. Compatibility • if, while, do-while, and switch statements, where the head syntax is Expression, which may be over-parenthesized. • try, catch, finally must be braced as in ES3 and ES5. • catch heads may be parenthesized or unparenthesized. Saturday, June 11, 2011
  • 15. Compatibility • if, while, do-while, and switch statements, where the head syntax is Expression, which may be over-parenthesized. • try, catch, finally must be braced as in ES3 and ES5. • catch heads may be parenthesized or unparenthesized. • for heads may be parenthesized or unparenthesized. Saturday, June 11, 2011
  • 16. Compatibility • if, while, do-while, and switch statements, where the head syntax is Expression, which may be over-parenthesized. • try, catch, finally must be braced as in ES3 and ES5. • catch heads may be parenthesized or unparenthesized. • for heads may be parenthesized or unparenthesized. • for-in/of heads may be parenthesized or unparenthesized. Saturday, June 11, 2011
  • 17. Compatibility • if, while, do-while, and switch statements, where the head syntax is Expression, which may be over-parenthesized. • try, catch, finally must be braced as in ES3 and ES5. • catch heads may be parenthesized or unparenthesized. • for heads may be parenthesized or unparenthesized. • for-in/of heads may be parenthesized or unparenthesized. • for-of loop, comprehension, and generator expression new semantics (next slide). Saturday, June 11, 2011
  • 18. for-in & for-of Saturday, June 11, 2011
  • 19. for-in & for-of • for k in o iterates over keys not values for all objects o. Saturday, June 11, 2011
  • 20. for-in & for-of • for k in o iterates over keys not values for all objects o. • for k of {p:1, q:2} iterates over 1, 2. Saturday, June 11, 2011
  • 21. for-in & for-of • for k in o iterates over keys not values for all objects o. • for k of {p:1, q:2} iterates over 1, 2. • for v of [3, 4, 5] iterates over 3, 4, 5. Saturday, June 11, 2011
  • 22. for-in & for-of • for k in o iterates over keys not values for all objects o. • for k of {p:1, q:2} iterates over 1, 2. • for v of [3, 4, 5] iterates over 3, 4, 5. • for k of keys(o) iterates over keys in o. Saturday, June 11, 2011
  • 23. for-in & for-of • for k in o iterates over keys not values for all objects o. • for k of {p:1, q:2} iterates over 1, 2. • for v of [3, 4, 5] iterates over 3, 4, 5. • for k of keys(o) iterates over keys in o. • for v of values(o) iterates over values in o. Saturday, June 11, 2011
  • 24. for-in & for-of • for k in o iterates over keys not values for all objects o. • for k of {p:1, q:2} iterates over 1, 2. • for v of [3, 4, 5] iterates over 3, 4, 5. • for k of keys(o) iterates over keys in o. • for v of values(o) iterates over values in o. • for [k, v] of items(o) iterates over key/value pairs. Saturday, June 11, 2011
  • 25. for-in & for-of • for k in o iterates over keys not values for all objects o. • for k of {p:1, q:2} iterates over 1, 2. • for v of [3, 4, 5] iterates over 3, 4, 5. • for k of keys(o) iterates over keys in o. • for v of values(o) iterates over values in o. • for [k, v] of items(o) iterates over key/value pairs. • for x of proxy iterates using the handler iterate trap. (http://wiki.ecmascript.org/doku.php?id=harmony:iterators) Saturday, June 11, 2011