Javascript: the Definitive Guide, Seventh Edition

Total Page:16

File Type:pdf, Size:1020Kb

Javascript: the Definitive Guide, Seventh Edition Seventh Edition JavaScript The Definitive Guide Master the World's Most-Used Programming Language David Flanagan Praise for JavaScript: The Definitive Guide, Seventh Edition “This book is everything you never knew you wanted to know about JavaScript. Take your JavaScript code quality and productivity to the next level. David’s knowledge of the language, its intricacies and gotchas, is astounding, and it shines through in this truly definitive guide to the JavaScript language.” —Schalk Neethling, Senior Frontend Engineer at MDN Web Docs “David Flanagan takes readers on a guided tour of JavaScript that will provide them with a feature-complete picture of the language and its ecosystem.” —Sarah Wachs, Frontend Developer and Women Who Code Berlin Lead “Any developer interested in being productive in codebases developed throughout JavaScript’s lifetime (including the latest and emerging features) will be well served by a deep and reflective journey through this comprehensive and definitive book.” —Brian Sletten, President of Bosatsu Consulting SEVENTH EDITION JavaScript: The Definitive Guide Master the World’s Most-Used Programming Language David Flanagan Beijing Boston Farnham Sebastopol Tokyo JavaScript: The Definitive Guide, Seventh Edition by David Flanagan Copyright © 2020 David Flanagan. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Acquisitions Editor: Jennifer Pollock Indexer: Judith McConville Development Editor: Angela Rufino Interior Designer: David Futato Production Editor: Deborah Baker Cover Designer: Karen Montgomery Copyeditor: Holly Bauer Forsyth Illustrator: Rebecca Demarest Proofreader: Piper Editorial, LLC June 1998: Third Edition November 2001: Fourth Edition August 2006: Fifth Edition May 2011: Sixth Edition May 2020: Seventh Edition Revision History for the Seventh Edition 2020-05-13: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491952023 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. JavaScript: The Definitive Guide, Sev‐ enth Edition, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-491-95202-3 [LSI] To my parents, Donna and Matt, with love and gratitude. Table of Contents Preface. xiii 1. Introduction to JavaScript. 1 1.1 Exploring JavaScript 3 1.2 Hello World 5 1.3 A Tour of JavaScript 5 1.4 Example: Character Frequency Histograms 11 1.5 Summary 14 2. Lexical Structure. 15 2.1 The Text of a JavaScript Program 15 2.2 Comments 16 2.3 Literals 16 2.4 Identifiers and Reserved Words 16 2.5 Unicode 17 2.6 Optional Semicolons 19 2.7 Summary 21 3. Types, Values, and Variables. 23 3.1 Overview and Definitions 23 3.2 Numbers 25 3.3 Text 32 3.4 Boolean Values 38 3.5 null and undefined 40 3.6 Symbols 41 3.7 The Global Object 42 3.8 Immutable Primitive Values and Mutable Object References 43 3.9 Type Conversions 45 vii 3.10 Variable Declaration and Assignment 53 3.11 Summary 60 4. Expressions and Operators. 61 4.1 Primary Expressions 62 4.2 Object and Array Initializers 62 4.3 Function Definition Expressions 63 4.4 Property Access Expressions 64 4.5 Invocation Expressions 66 4.6 Object Creation Expressions 68 4.7 Operator Overview 68 4.8 Arithmetic Expressions 73 4.9 Relational Expressions 78 4.10 Logical Expressions 84 4.11 Assignment Expressions 86 4.12 Evaluation Expressions 88 4.13 Miscellaneous Operators 91 4.14 Summary 96 5. Statements. 97 5.1 Expression Statements 98 5.2 Compound and Empty Statements 99 5.3 Conditionals 100 5.4 Loops 105 5.5 Jumps 112 5.6 Miscellaneous Statements 121 5.7 Declarations 124 5.8 Summary of JavaScript Statements 127 6. Objects. 129 6.1 Introduction to Objects 129 6.2 Creating Objects 130 6.3 Querying and Setting Properties 133 6.4 Deleting Properties 138 6.5 Testing Properties 139 6.6 Enumerating Properties 140 6.7 Extending Objects 142 6.8 Serializing Objects 143 6.9 Object Methods 144 6.10 Extended Object Literal Syntax 146 6.11 Summary 153 viii | Table of Contents 7. Arrays. 155 7.1 Creating Arrays 156 7.2 Reading and Writing Array Elements 159 7.3 Sparse Arrays 160 7.4 Array Length 161 7.5 Adding and Deleting Array Elements 161 7.6 Iterating Arrays 162 7.7 Multidimensional Arrays 164 7.8 Array Methods 165 7.9 Array-Like Objects 177 7.10 Strings as Arrays 179 7.11 Summary 180 8. Functions. 181 8.1 Defining Functions 182 8.2 Invoking Functions 186 8.3 Function Arguments and Parameters 193 8.4 Functions as Values 200 8.5 Functions as Namespaces 203 8.6 Closures 204 8.7 Function Properties, Methods, and Constructor 209 8.8 Functional Programming 213 8.9 Summary 219 9. Classes. 221 9.1 Classes and Prototypes 222 9.2 Classes and Constructors 224 9.3 Classes with the class Keyword 229 9.4 Adding Methods to Existing Classes 236 9.5 Subclasses 237 9.6 Summary 248 10. Modules. 249 10.1 Modules with Classes, Objects, and Closures 250 10.2 Modules in Node 253 10.3 Modules in ES6 255 10.4 Summary 266 11. The JavaScript Standard Library. 267 11.1 Sets and Maps 268 11.2 Typed Arrays and Binary Data 275 11.3 Pattern Matching with Regular Expressions 281 Table of Contents | ix 11.4 Dates and Times 300 11.5 Error Classes 304 11.6 JSON Serialization and Parsing 306 11.7 The Internationalization API 309 11.8 The Console API 317 11.9 URL APIs 320 11.10 Timers 323 11.11 Summary 325 12. Iterators and Generators. 327 12.1 How Iterators Work 328 12.2 Implementing Iterable Objects 329 12.3 Generators 332 12.4 Advanced Generator Features 336 12.5 Summary 339 13. Asynchronous JavaScript. 341 13.1 Asynchronous Programming with Callbacks 342 13.2 Promises 346 13.3 async and await 367 13.4 Asynchronous Iteration 370 13.5 Summary 377 14. Metaprogramming. 379 14.1 Property Attributes 380 14.2 Object Extensibility 384 14.3 The prototype Attribute 386 14.4 Well-Known Symbols 387 14.5 Template Tags 395 14.6 The Reflect API 397 14.7 Proxy Objects 399 14.8 Summary 406 15. JavaScript in Web Browsers. 409 15.1 Web Programming Basics 411 15.2 Events 426 15.3 Scripting Documents 437 15.4 Scripting CSS 452 15.5 Document Geometry and Scrolling 459 15.6 Web Components 464 15.7 SVG: Scalable Vector Graphics 477 15.8 Graphics in a <canvas> 484 x | Table of Contents 15.9 Audio APIs 507 15.10 Location, Navigation, and History 509 15.11 Networking 518 15.12 Storage 536 15.13 Worker Threads and Messaging 548 15.14 Example: The Mandelbrot Set 555 15.15 Summary and Suggestions for Further Reading 568 16. Server-Side JavaScript with Node. 577 16.1 Node Programming Basics 578 16.2 Node Is Asynchronous by Default 583 16.3 Buffers 586 16.4 Events and EventEmitter 588 16.5 Streams 590 16.6 Process, CPU, and Operating System Details 601 16.7 Working with Files 602 16.8 HTTP Clients and Servers 613 16.9 Non-HTTP Network Servers and Clients 617 16.10 Working with Child Processes 620 16.11 Worker Threads 625 16.12 Summary 634 17. JavaScript Tools and Extensions. 635 17.1 Linting with ESLint 636 17.2 JavaScript Formatting with Prettier 637 17.3 Unit Testing with Jest 638 17.4 Package Management with npm 640 17.5 Code Bundling 642 17.6 Transpilation with Babel 644 17.7 JSX: Markup Expressions in JavaScript 645 17.8 Type Checking with Flow 649 17.9 Summary 665 Index. 667 Table of Contents | xi Preface This book covers the JavaScript language and the JavaScript APIs implemented by web browsers and by Node. I wrote it for readers with some prior programming experience who want to learn JavaScript and also for programmers who already use JavaScript but want to take their understanding to a new level and really master the language. My goal with this book is to document the JavaScript language comprehen‐ sively and definitively and to provide an in-depth introduction to the most important client-side and server-side APIs available to JavaScript programs. As a result, this is a long and detailed book. My hope, however, is that it will reward careful study and that the time you spend reading it will be easily recouped in the form of higher pro‐ gramming productivity. Previous editions of this book included a comprehensive reference section. I no longer feel that it makes sense to include that material in printed form when it is so quick and easy to find up-to-date reference material online.
Recommended publications
  • X10 Language Specification
    X10 Language Specification Version 2.6.2 Vijay Saraswat, Bard Bloom, Igor Peshansky, Olivier Tardieu, and David Grove Please send comments to [email protected] January 4, 2019 This report provides a description of the programming language X10. X10 is a class- based object-oriented programming language designed for high-performance, high- productivity computing on high-end computers supporting ≈ 105 hardware threads and ≈ 1015 operations per second. X10 is based on state-of-the-art object-oriented programming languages and deviates from them only as necessary to support its design goals. The language is intended to have a simple and clear semantics and be readily accessible to mainstream OO pro- grammers. It is intended to support a wide variety of concurrent programming idioms. The X10 design team consists of David Grove, Ben Herta, Louis Mandel, Josh Milthorpe, Vijay Saraswat, Avraham Shinnar, Mikio Takeuchi, Olivier Tardieu. Past members include Shivali Agarwal, Bowen Alpern, David Bacon, Raj Barik, Ganesh Bikshandi, Bob Blainey, Bard Bloom, Philippe Charles, Perry Cheng, David Cun- ningham, Christopher Donawa, Julian Dolby, Kemal Ebcioglu,˘ Stephen Fink, Robert Fuhrer, Patrick Gallop, Christian Grothoff, Hiroshi Horii, Kiyokuni Kawachiya, Al- lan Kielstra, Sreedhar Kodali, Sriram Krishnamoorthy, Yan Li, Bruce Lucas, Yuki Makino, Nathaniel Nystrom, Igor Peshansky, Vivek Sarkar, Armando Solar-Lezama, S. Alexander Spoon, Toshio Suganuma, Sayantan Sur, Toyotaro Suzumura, Christoph von Praun, Leena Unnikrishnan, Pradeep Varma, Krishna Nandivada Venkata, Jan Vitek, Hai Chuan Wang, Tong Wen, Salikh Zakirov, and Yoav Zibin. For extended discussions and support we would like to thank: Gheorghe Almasi, Robert Blackmore, Rob O’Callahan, Calin Cascaval, Norman Cohen, Elmootaz El- nozahy, John Field, Kevin Gildea, Sara Salem Hamouda, Michihiro Horie, Arun Iyen- gar, Chulho Kim, Orren Krieger, Doug Lea, John McCalpin, Paul McKenney, Hiroki Murata, Andrew Myers, Filip Pizlo, Ram Rajamony, R.
    [Show full text]
  • Exploring Languages with Interpreters and Functional Programming Chapter 22
    Exploring Languages with Interpreters and Functional Programming Chapter 22 H. Conrad Cunningham 5 November 2018 Contents 22 Overloading and Type Classes 2 22.1 Chapter Introduction . .2 22.2 Polymorphism in Haskell . .2 22.3 Why Overloading? . .2 22.4 Defining an Equality Class and Its Instances . .4 22.5 Type Class Laws . .5 22.6 Another Example Class Visible ..................5 22.7 Class Extension (Inheritance) . .6 22.8 Multiple Constraints . .7 22.9 Built-In Haskell Classes . .8 22.10Comparison to Other Languages . .8 22.11What Next? . .9 22.12Exercises . 10 22.13Acknowledgements . 10 22.14References . 11 22.15Terms and Concepts . 11 Copyright (C) 2017, 2018, H. Conrad Cunningham Professor of Computer and Information Science University of Mississippi 211 Weir Hall P.O. Box 1848 University, MS 38677 (662) 915-5358 Browser Advisory: The HTML version of this textbook requires use of a browser that supports the display of MathML. A good choice as of November 2018 is a recent version of Firefox from Mozilla. 1 22 Overloading and Type Classes 22.1 Chapter Introduction Chapter 5 introduced the concept of overloading. Chapters 13 and 21 introduced the related concepts of type classes and instances. The goal of this chapter and the next chapter is to explore these concepts in more detail. The concept of type class was introduced into Haskell to handle the problem of comparisons, but it has had a broader and more profound impact upon the development of the language than its original purpose. This Haskell feature has also had a significant impact upon the design of subsequent languages (e.g.
    [Show full text]
  • Programming Language Integrated Semantic Queries and Types
    Semantics4J – Programming Language Integrated Semantic Queries and Types Masterarbeit zur Erlangung des Grades eines Master of Science im Studiengang MSc Informatik vorgelegt von Carsten Hartenfels Erstgutachter: Prof. Dr. Ralf Lämmel Institut für Informatik Zweitgutachter: MSc. Martin Leinberger Institut für Informatik Koblenz, im August 2017 Erklärung Hiermit bestätige ich, dass die vorliegende Arbeit von mir selbständig ver- fasst wurde und ich keine anderen als die angegebenen Hilfsmittel – ins- besondere keine im Quellenverzeichnis nicht benannten Internet-Quellen – benutzt habe und die Arbeitvon mir vorher nicht in einem anderen Prü- fungsverfahren eingereicht wurde. Die eingereichte schriftliche Fassung entspricht der auf dem elektronischen Speichermedium (CD-ROM). Ja Nein Mit der Einstellung der Arbeit in die Bibliothek bin ich ein- verstanden. Der Veröffentlichung dieser Arbeit im Internet stimme ich zu. ................................................................................ (Ort, Datum) (Carsten Hartenfels) Zusammenfassung Semantische Daten zusammen mit General-Purpose-Programmiersprachen zu ver- wenden stellt nicht die einheitlichen Eigenschaften bereit, die man für eine solche Verwendung haben möchte. Die statische Fehlererkennung ist mangelhaft, ins- besondere der statischen Typisierung anbetreffend. Basierend auf vorangegan- gener Arbeit an λDL, welches semantische Queries und Konzepte als Datentypen in ein typisiertes λ-Kalkül integriert, bringt dieses Werk dessen Ideen einen Schritt weiter, um es in eine Echtwelt-Programmiersprache zu integrieren. Diese Arbeit untersucht, wie λDLs Features erweitert und mit einer existierende Sprache vere- inigt werden können, erforscht einen passenden Erweiterungsmechanismus und pro- duziert Semantics4J, eine JastAdd-basierte Java-Sprachintegration für semantis- che Daten für typsichere OWL-Programmierung, zusammen mit Beispielen für ihre Verwendung. Abstract Using semantic data from general-purpose programming languages does not pro- vide the unified experience one would want for such an application.
    [Show full text]
  • On the Interaction of Object-Oriented Design Patterns and Programming
    On the Interaction of Object-Oriented Design Patterns and Programming Languages Gerald Baumgartner∗ Konstantin L¨aufer∗∗ Vincent F. Russo∗∗∗ ∗ Department of Computer and Information Science The Ohio State University 395 Dreese Lab., 2015 Neil Ave. Columbus, OH 43210–1277, USA [email protected] ∗∗ Department of Mathematical and Computer Sciences Loyola University Chicago 6525 N. Sheridan Rd. Chicago, IL 60626, USA [email protected] ∗∗∗ Lycos, Inc. 400–2 Totten Pond Rd. Waltham, MA 02154, USA [email protected] February 29, 1996 Abstract Design patterns are distilled from many real systems to catalog common programming practice. However, some object-oriented design patterns are distorted or overly complicated because of the lack of supporting programming language constructs or mechanisms. For this paper, we have analyzed several published design patterns looking for idiomatic ways of working around constraints of the implemen- tation language. From this analysis, we lay a groundwork of general-purpose language constructs and mechanisms that, if provided by a statically typed, object-oriented language, would better support the arXiv:1905.13674v1 [cs.PL] 31 May 2019 implementation of design patterns and, transitively, benefit the construction of many real systems. In particular, our catalog of language constructs includes subtyping separate from inheritance, lexically scoped closure objects independent of classes, and multimethod dispatch. The proposed constructs and mechanisms are not radically new, but rather are adopted from a variety of languages and programming language research and combined in a new, orthogonal manner. We argue that by describing design pat- terns in terms of the proposed constructs and mechanisms, pattern descriptions become simpler and, therefore, accessible to a larger number of language communities.
    [Show full text]
  • An Analysis of the Dynamic Behavior of Javascript Programs
    An Analysis of the Dynamic Behavior of JavaScript Programs Gregor Richards Sylvain Lebresne Brian Burg Jan Vitek S3 Lab, Department of Computer Science, Purdue University, West Lafayette, IN fgkrichar,slebresn,bburg,[email protected] Abstract becoming a general purpose computing platform with office appli- The JavaScript programming language is widely used for web cations, browsers and development environments [15] being devel- programming and, increasingly, for general purpose computing. oped in JavaScript. It has been dubbed the “assembly language” of the Internet and is targeted by code generators from the likes As such, improving the correctness, security and performance of 2;3 JavaScript applications has been the driving force for research in of Java and Scheme [20]. In response to this success, JavaScript type systems, static analysis and compiler techniques for this lan- has started to garner academic attention and respect. Researchers guage. Many of these techniques aim to reign in some of the most have focused on three main problems: security, correctness and dynamic features of the language, yet little seems to be known performance. Security is arguably JavaScript’s most pressing prob- about how programmers actually utilize the language or these fea- lem: a number of attacks have been discovered that exploit the lan- tures. In this paper we perform an empirical study of the dynamic guage’s dynamism (mostly the ability to access and modify shared behavior of a corpus of widely-used JavaScript programs, and an- objects and to inject code via eval). Researchers have proposed ap- alyze how and why the dynamic features are used.
    [Show full text]
  • Thinking in C++ Volume 2 Annotated Solution Guide, Available for a Small Fee From
    1 z 516 Note: This document requires the installation of the fonts Georgia, Verdana and Andale Mono (code font) for proper viewing. These can be found at: http://sourceforge.net/project/showfiles.php?group_id=34153&release_id=105355 Revision 19—(August 23, 2003) Finished Chapter 11, which is now going through review and copyediting. Modified a number of examples throughout the book so that they will compile with Linux g++ (basically fixing case- sensitive naming issues). Revision 18—(August 2, 2003) Chapter 5 is complete. Chapter 11 is updated and is near completion. Updated the front matter and index entries. Home stretch now. Revision 17—(July 8, 2003) Chapters 5 and 11 are 90% done! Revision 16—(June 25, 2003) Chapter 5 text is almost complete, but enough is added to justify a separate posting. The example programs for Chapter 11 are also fairly complete. Added a matrix multiplication example to the valarray material in chapter 7. Chapter 7 has been tech-edited. Many corrections due to comments from users have been integrated into the text (thanks!). Revision 15—(March 1 ,2003) Fixed an omission in C10:CuriousSingleton.cpp. Chapters 9 and 10 have been tech-edited. Revision 14—(January ,2003) Fixed a number of fuzzy explanations in response to reader feedback (thanks!). Chapter 9 has been copy-edited. Revision 13—(December 31, 2002) Updated the exercises for Chapter 7. Finished rewriting Chapter 9. Added a template variation of Singleton to chapter 10. Updated the build directives. Fixed lots of stuff. Chapters 5 and 11 still await rewrite. Revision 12—(December 23, 2002) Added material on Design Patterns as Chapter 10 (Concurrency will move to Chapter 11).
    [Show full text]
  • New E-Items Added 3 20 to 3 26 2018 1 Title Author Publisher Published
    New E-items added 3 20 to 3 26 2018 Title Author Publisher Published Location Call Number Class Subject Johann Georg Hamann's doctrine of Lee, Hoon J. (Hoon Trinity 2008 Ebooks - LU B 2993 L 444 B B - Philosophy nature [electronic resource] / by Jae) International users only 2008 EB (General) Hoon J. Lee. University Modernity and its malcontents Nicholson, Michael 1995 Ebooks - LU B 8312 N 53 B B - Philosophy [electronic resource] / Michael W. W. users only 1995 EB (General) Nicholson. Social understanding [electronic Klüver, Jürgen, Springer 2011 Ebooks - LU BD 241 K 58 BD BD - resource] : on hermeneutics, 1941- users only 2011 EB Speculative geometrical models and artificial Philosophy intelligence / Jürgen Klüver, Christina Klüver. Musical bonding [electronic Percival, Hannah Criswell College 2015 Ebooks - LU BF 1045 A 48 BF BF - Psychology, resource] / by Hannah Margaret Margaret, users only P 473 2015 EB Parapsychology, Percival. Occult Sciences Multi-dimensional spirituality and Lewis, Melissa. 2007 Ebooks - LU BF 575 S 75 L BF BF - Psychology, vicarious trauma [electronic users only 49 2007 EB Parapsychology, resource] : exploring the Occult Sciences relationship / by Melissa Lewis. Ministry coaching [electronic Asche, Darrell Emmanuel School 2008 Ebooks - LU BF 637 M 45 BF BF - Psychology, resource] : a means of leadership (Darrell Earl), 1982- of Religion users only A 83 2008 EB Parapsychology, development / by Darrell Asche. Occult Sciences Ministering to grieving children Matthews, Louis 2003 Ebooks - LU BF 723 G 75 BF BF - Psychology, [electronic resource] / by Louis (Louis G.) users only M 38 2003 EB Parapsychology, Matthews. Occult Sciences 1 New E-items added 3 20 to 3 26 2018 Jonathan Edwards' moral theology Frost, R.
    [Show full text]
  • BROWSE Inspecting the Constituents of Webpages and Detecting Malware on the Internet
    BROWSE Inspecting the constituents of webpages and Detecting malware on the internet. Computing Science Department Radboud University The Netherlands ing. Vinesh Kali Supervisors: dr. Marko van Eekelen drs. Pieter Claassen Thesis-nr: 583 CONTENTS CONTENTS Contents 1 Introduction 1 1.1 Surfing on the internet ........................ 1 1.2 Security concerns ........................... 2 1.3 Research ................................ 3 2 The internet from a webbrowser view 4 2.1 Webpages ............................... 4 2.1.1 HTML ............................. 4 2.1.2 XHTML ............................ 5 2.1.3 Third party plug-ins ..................... 5 2.2 The HTML Document Object Model (DOM) ........... 6 2.2.1 The model explained ..................... 6 2.2.2 Implementation in the webbrowser ............. 6 2.3 JavaScript and the webbrowser ................... 7 2.3.1 Asynchronous JavaScript and XML (AJAX) ....... 8 2.3.2 JavaScript Security ...................... 9 3 Common JavaScript attacks hidden inside webpages 11 3.1 Denial of Service attacks ....................... 11 3.2 Cross Site Scripting (XSS) ...................... 13 3.2.1 An example of a reflected XSS attack ........... 13 3.3 Session hijacking or Cross Site Request Forgery (CSRF) ..... 15 3.3.1 An example of a CSRF attack ............... 15 4 Inspecting webpages with the BROWSE application 17 4.1 BROWSE in concept ......................... 17 4.2 The architecture of BROWSE .................... 18 i CONTENTS CONTENTS 5 How does BROWSE work 19 5.1 Collecting and parsing the webpage ................. 19 5.2 Parsing with XPath ......................... 19 5.2.1 The XPath Syntax ...................... 19 5.2.2 Using Xpath to find URLs .................. 20 5.2.3 Filter out the JavaScript ................... 21 5.3 Analyse the HTML tags and JavaScript .............
    [Show full text]
  • Document Object Model †DOM‡ Level 1 Specification
    Document Object Model (DOM) Level 1 Specification REC-DOM-Level-1-19981001 Document Object Model (DOM) Level 1 Specification Version 1.0 W3C Recommendation 1 October, 1998 This version http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001 http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.ps http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.pdf http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.tgz http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.zip http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/DOM.txt Latest version http://www.w3.org/TR/REC-DOM-Level-1 Previous versions http://www.w3.org/TR/1998/PR-DOM-Level-1-19980818 http://www.w3.org/TR/1998/WD-DOM-19980720 http://www.w3.org/TR/1998/WD-DOM-19980416 http://www.w3.org/TR/WD-DOM-19980318 http://www.w3.org/TR/WD-DOM-971209 http://www.w3.org/TR/WD-DOM-971009 WG Chair Lauren Wood, SoftQuad, Inc. Editors Vidur Apparao, Netscape Steve Byrne, Sun Mike Champion, ArborText Scott Isaacs, Microsoft Ian Jacobs, W3C Arnaud Le Hors, W3C Gavin Nicol, Inso EPS Jonathan Robie, Texcel Research Robert Sutor, IBM Chris Wilson, Microsoft Lauren Wood, SoftQuad, Inc. Principal Contributors Vidur Apparao, Netscape Steve Byrne, Sun (until November 1997) Mike Champion, ArborText, Inc. 1 Status of this document Scott Isaacs, Microsoft (until January, 1998) Arnaud Le Hors, W3C Gavin Nicol, Inso EPS Jonathan Robie, Texcel Research Peter Sharpe, SoftQuad, Inc. Bill Smith, Sun (after November 1997) Jared Sorensen, Novell Robert Sutor, IBM Ray Whitmer, iMall Chris Wilson, Microsoft (after January, 1998) Status of this document This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a W3C Recommendation.
    [Show full text]
  • Ferrite: a Judgmental Embedding of Session Types in Rust
    Ferrite: A Judgmental Embedding of Session Types in Rust RUOFEI CHEN, Independent Researcher, Germany STEPHANIE BALZER, Carnegie Mellon University, USA This paper introduces Ferrite, a shallow embedding of session types in Rust. In contrast to existing session type libraries and embeddings for mainstream languages, Ferrite not only supports linear session types but also shared session types. Shared session types allow sharing (aliasing) of channels while preserving session fidelity (preservation) using type modalities for acquiring and releasing sessions. Ferrite adopts a propositions as types approach and encodes typing derivations as Rust functions, with the proof of successful type-checking manifesting as a Rust program. We provide an evaluation of Ferrite using Servo as a practical example, and demonstrate how safe communication can be achieved in the canvas component using Ferrite. CCS Concepts: • Theory of computation ! Linear logic; Type theory; • Software and its engineering ! Domain specific languages; Concurrent programming languages. Additional Key Words and Phrases: Session Types, Rust, DSL ACM Reference Format: Ruofei Chen and Stephanie Balzer. 2021. Ferrite: A Judgmental Embedding of Session Types in Rust. In Proceedings of International Conference on Functional Programming (ICFP 2021). ACM, New York, NY, USA, 36 pages. 1 INTRODUCTION Message-passing concurrency is a dominant concurrency paradigm, adopted by mainstream lan- guages such as Erlang, Scala, Go, and Rust, putting the slogan “to share memory by communicating rather than communicating by sharing memory”[Gerrand 2010; Klabnik and Nichols 2018] into practice. In this setting, messages are exchanged over channels, which can be shared among several senders and recipients. Figure 1 provides a simplified example in Rust.
    [Show full text]
  • Asynchronous Liquid Separation Types
    Asynchronous Liquid Separation Types Johannes Kloos, Rupak Majumdar, and Viktor Vafeiadis Max Planck Institute for Software Systems, Germany { jkloos, rupak, viktor }@mpi-sws.org Abstract We present a refinement type system for reasoning about asynchronous programs manipulating shared mutable state. Our type system guarantees the absence of races and the preservation of user-specified invariants using a combination of two ideas: refinement types and concurrent separation logic. Our type system allows precise reasoning about programs using two ingredients. First, our types are indexed by sets of resource names and the type system tracks the effect of program execution on individual heap locations and task handles. In particular, it allows making strong updates to the types of heap locations. Second, our types track ownership of shared state across concurrently posted tasks and allow reasoning about ownership transfer between tasks using permissions. We demonstrate through several examples that these two ingredients, on top of the framework of liquid types, are powerful enough to reason about correct behavior of practical, complex, asynchronous systems manipulating shared heap resources. We have implemented type inference for our type system and have used it to prove complex invariants of asynchronous OCaml programs. We also show how the type system detects subtle concurrency bugs in a file system implementation. 1998 ACM Subject Classification F.3.1 Specifying and Verifying and Reasoning about Pro- grams, D.2.4 Software/Program Verification Keywords and phrases Liquid Types, Asynchronous Parallelism, Separation Logic, Type Sys- tems 1 Introduction Asynchronous programming is a common programming idiom used to handle concurrent interactions. It is commonly used not only in low-level systems code, such as operating systems kernels and device drivers, but also in internet services, in programming models for mobile applications, in GUI event loops, and in embedded systems.
    [Show full text]
  • Thinking in C++ 2Nd Edition Volume 2
    Thinking in C++ 2nd edition Volume 2: Standard Libraries & Advanced Topics To be informed of future releases of this document and other information about object- oriented books, documents, seminars and CDs, subscribe to my free newsletter. Just send any email to: [email protected] ________________________________________________________________________ “This book is a tremendous achievement. You owe it to yourself to have a copy on your shelf. The chapter on iostreams is the most comprehensive and understandable treatment of that subject I’ve seen to date.” Al Stevens Contributing Editor, Doctor Dobbs Journal “Eckel’s book is the only one to so clearly explain how to rethink program construction for object orientation. That the book is also an excellent tutorial on the ins and outs of C++ is an added bonus.” Andrew Binstock Editor, Unix Review “Bruce continues to amaze me with his insight into C++, and Thinking in C++ is his best collection of ideas yet. If you want clear answers to difficult questions about C++, buy this outstanding book.” Gary Entsminger Author, The Tao of Objects “Thinking in C++ patiently and methodically explores the issues of when and how to use inlines, references, operator overloading, inheritance and dynamic objects, as well as advanced topics such as the proper use of templates, exceptions and multiple inheritance. The entire effort is woven in a fabric that includes Eckel’s own philosophy of object and program design. A must for every C++ developer’s bookshelf, Thinking in C++ is the one C++ book you must have if you’re doing serious development with C++.” Richard Hale Shaw Contributing Editor, PC Magazine Thinking In C++ 2nd Edition, Volume 2 Bruce Eckel President, MindView Inc.
    [Show full text]