Ebooks File JavaScript: The New Toys T. J. Crowder All Chapters
Ebooks File JavaScript: The New Toys T. J. Crowder All Chapters
com
OR CLICK BUTTON
DOWLOAD EBOOK
JavaScript T. J. Crowder
https://ebookmass.com/product/javascript-t-j-crowder/
https://ebookmass.com/product/ethnopolitics-in-the-new-europe-
john-t-ishiyama/
https://ebookmass.com/product/understanding-the-physics-of-toys-
s-rajasekar/
https://ebookmass.com/product/new-perspectives-on-html5-css3-and-
javascript-6th-edition-patrick-carey/
Toys and Communication 1st Edition Luísa Magalhães
https://ebookmass.com/product/toys-and-communication-1st-edition-
luisa-magalhaes/
https://ebookmass.com/product/the-marketing-of-childrens-
toys-1st-ed-2021-edition-rebecca-c-hains/
https://ebookmass.com/product/technopopulism-the-new-logic-of-
democratic-politics-christopher-j-bickerton/
https://ebookmass.com/product/javascript-crash-course-the-
complete-beginners-guide-to-learning-javascript-programming-in-
no-time-angularjs-jquery-javascript-visually-nathaniel-hill/
https://ebookmass.com/product/forging-a-new-south-the-life-of-
general-john-t-wilder-1st-edition-nicely/
JavaScript®
THE NEW TOYS
T.J. Crowder
www.allitebooks.com
JAVASCRIPT®
THE NEW TOYS
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
www.allitebooks.com
JavaScript®
The New Toys
www.allitebooks.com
JavaScript®: The New Toys
Copyright © 2020 by Thomas Scott “T.J.” Crowder
ISBN: 978-1-119-36797-6
ISBN: 978-1-119-36797-0 (ebk)
ISBN: 978-1-119-36796-3 (ebk)
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of
the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923,
(978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online
at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect
to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without
limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional
materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the
understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional
assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author
shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation
and/or a potential source of further information does not mean that the author or the publisher endorses the information the
organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web
sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United
States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print
versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD
that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com.
For more information about Wiley products, visit www.wiley.com.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries,
and may not be used without written permission. JavaScript is a registered trademark of Oracle America, Inc. All other
trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or
vendor mentioned in this book.
www.allitebooks.com
To Wendy and James, who’ve met late nights and
working weekends with unstinting support and
loving encouragement.
www.allitebooks.com
ABOUT THE AUTHOR
T.J. CROWDER is a software engineer with 30 years of professional experience, at least half that time
working with JavaScript. He runs Farsight Software, a UK software consulting and product company.
As one of the top 10 contributors on Stack Overflow and the top contributor in the JavaScript tag, he
likes to use what he’s learned to help others with the technical challenges they’re facing, with an
emphasis not just on imparting knowledge, but on helping with the process of solving problems.
T.J. started programming in his early teens in California, playing around with the Apple II and
Sinclair ZX-80 and -81 using BASIC and assembly language. He got his first proper job with comput-
ers many years later, working a technical support position for a company with a PC (DOS) product
for court reporters. While working support, he taught himself C from the TurboC manuals in the
office, reverse-engineered the company’s undocumented, compressed binary file format, and used
that knowledge to create a much-requested feature for the product in his spare time (one the com-
pany soon started shipping). Before long the development department took him in and over the next
several years gave him the opportunity, resources, and responsibility to grow into a programmer and,
eventually, into their lead engineer, creating various products including their first Windows product.
At his next company he took on a professional services and developer education role that saw him
customizing the company’s enterprise product on-site for clients (using VB6, JavaScript, and HTML)
and teaching training classes to the clients’ developers; eventually he was writing the training classes.
A move from the U.S. to London put him back in a straight development role where he was able to
increase his software design, SQL, Java, and JavaScript skills before branching out into independent
contracting.
Since then through circumstance he’s been doing primarily closed-source remote development work
for a variety of companies and organizations (a NATO agency, a UK local government authority, and
various private firms) working primarily in JavaScript, SQL, C#, and (recently) TypeScript. The desire
for community led him first to the PrototypeJS mailing list back in the day, then to Stack Overflow,
and now to various platforms.
English and American by birth, American by upbringing, T.J. lives in a village in central England with
his wife and son.
ABOUT THE TECHNICAL EDITOR
CHAIM KRAUSE is an expert computer programmer with over thirty years of experience to prove it.
He has worked as a lead tech support engineer for ISPs as early as 1995, as a senior developer sup-
port engineer with Borland for Delphi, and has worked in Silicon Valley for over a decade in various
roles, including technical support engineer and developer support engineer. He is currently a military
simulation specialist for the US Army’s Command and General Staff College, working on projects
such as developing serious games for use in training exercises. He has also authored several video
training courses on Linux topics, and has been a technical reviewer for over two dozen books.
ABOUT THE TECHNICAL PROOFREADER
INTRODUCTION xxxi
CHAPTER 4: CLASSES 65
What Is a Class? 66
Introducing the New class Syntax 66
Adding a Constructor 68
Adding Instance Properties 70
Adding a Prototype Method 70
Adding a Static Method 72
Adding an Accessor Property 73
Computed Method Names 74
Comparing with the Older Syntax 75
xviii
Contents
Creating Subclasses 77
The super Keyword 81
Writing Subclass Constructors 81
Inheriting and Accessing Superclass Prototype Properties and Methods 83
Inheriting Static Methods 86
super in Static Methods 88
Methods Returning New Instances 88
Subclassing Built-ins 93
Where super Is Available 94
Leaving Off Object.prototype 97
new.target 98
class Declarations vs. class Expressions 101
class Declarations 101
class Expressions 102
More to Come 103
Old Habits to New 104
Use class When Creating Constructor Functions 104
Iterators, Iterables, the for-of Loop, and Iterable Spread Syntax 131
Iterators and Iterables 132
The for-of Loop: Using an Iterator Implicitly 132
Using an Iterator Explicitly 133
Stopping Iteration Early 135
Iterator Prototype Objects 136
Making Something Iterable 138
Iterable Iterators 142
Iterable Spread Syntax 143
Iterators, for-of, and the DOM 144
Generator Functions 146
A Basic Generator Function Just Producing Values 147
Using Generator Functions to Create Iterators 148
Generator Functions As Methods 149
Using a Generator Directly 150
Consuming Values with Generators 151
Using return in a Generator Function 155
Precedence of the yield Operator 155
The return and throw Methods: Terminating a Generator 157
Yielding a Generator or Iterable: yield* 158
Old Habits to New 163
Use Constructs That Consume Iterables 163
Use DOM Collection Iteration Features 163
Use the Iterable and Iterator Interfaces 164
Use Iterable Spread Syntax in Most Places You Used
to Use Function.prototype.apply 164
Use Generators 164
xx
Contents
Overview 165
Basic Object Destructuring 166
Basic Array (and Iterable) Destructuring 169
Defaults 170
Rest Syntax in Destructuring Patterns 172
Using Different Names 173
Computed Property Names 174
Nested Destructuring 174
Parameter Destructuring 175
Destructuring in Loops 178
Old Habits to New 179
Use Destructuring When Getting Only Some Properties
from an Object 179
Use Destructuring for Options Objects 179
xxi
Contents
xxii
Contents
xxiii
Contents
Maps 293
Basic Map Operations 294
Key Equality 296
Creating Maps from Iterables 297
Iterating the Map Contents 297
Subclassing Map 299
Performance 300
Sets 300
Basic Set Operations 301
Creating Sets from Iterables 302
Iterating the Set Contents 302
Subclassing Set 303
Performance 304
WeakMaps 304
WeakMaps Are Not Iterable 305
Use Cases and Examples 305
Use Case: Private Information 305
Use Case: Storing Information for Objects Outside Your Control 307
Values Referring Back to the Key 308
xxiv
Contents
WeakSets 314
Use Case: Tracking 314
Use Case: Branding 315
Old Habits to New 316
Use Maps Instead of Objects for General-Purpose Maps 316
Use Sets Instead of Objects for Sets 316
Use WeakMaps for Storing Private Data Instead of Public Properties 317
xxv
Contents
Reflect 365
Reflect.apply 367
Reflect.construct 367
Reflect.ownKeys 368
Reflect.get, Reflect.set 369
Other Reflect Functions 370
Proxy 371
Example: Logging Proxy 373
Proxy Traps 381
Common Features 381
The apply Trap 381
The construct Trap 382
The defineProperty Trap 382
The deleteProperty Trap 384
The get Trap 385
The getOwnPropertyDescriptor Trap 386
The getPrototypeOf Trap 387
The has Trap 388
The isExtensible Trap 388
The ownKeys Trap 388
xxvi
Contents
xxvii
Another random document with
no related content on Scribd:
The bony plate ends just above the root of the nose.
The dissection is now carried on downward until the bones proper
of the nose appear, and latterly, so that the saw does not injure the
soft parts, and to act as a guide for the course of the latter.
The position of the flap and the saw in position is shown in Fig.
409.
In the Bonnet method the flap is taken from the entire thickness
of the upper lip and by twisting is brought into the defect. The
pedicle must be cut at a later sitting.
Fig. 436. Fig. 437.
Bonnet Method.
This defect of the nose has been restored by the use of skin flaps
taken from the forehead, the nose itself, or from half or the whole
thickness of the upper lip. The author does not advocate the use of
such flaps except those taken from the skin of the inner side of the
forearm, just below the wrist, made according to the Italian plan, as
heretofore described.
The pedicle of such a flap is cut about the twelfth day, and at a
later period, when the inferior or free margin has cicatrized, the
subseptum is formed and sutured to the remaining stump or into a
wound in the upper lip made to receive it.
The skin of the forearm is nearer to the thickness of the skin of
the nose; hence a flap from it is preferable to that taken from the
arm.
The method of obtaining the flap has been fully described
heretofore.
The results obtained are excellent in most cases. The resulting
cicatrix is barely visible, and may be later improved by scar-reducing
methods, later described under that heading.
The appearance of the flap after the pedicle has been severed and
the subseptal section has been put into place may be observed in
Fig. 456, and the final appearance after total contraction, in Fig. 457.
Fig. 456.—Flap detached.
Fig. 457.—Final appearance.
Author’s Case.
Restoration of Subseptum