100% found this document useful (1 vote)
23 views

Download Full JavaScript Next: Your Complete Guide to the New Features Introduced in JavaScript, Starting from ES6 to ES9 1st Edition Raju Gandhi PDF All Chapters

Starting

Uploaded by

hirterlydin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
23 views

Download Full JavaScript Next: Your Complete Guide to the New Features Introduced in JavaScript, Starting from ES6 to ES9 1st Edition Raju Gandhi PDF All Chapters

Starting

Uploaded by

hirterlydin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download Full Version ebook - Visit ebookmeta.

com

JavaScript Next: Your Complete Guide to the New


Features Introduced in JavaScript, Starting from
ES6 to ES9 1st Edition Raju Gandhi

https://ebookmeta.com/product/javascript-next-your-complete-
guide-to-the-new-features-introduced-in-javascript-starting-
from-es6-to-es9-1st-edition-raju-gandhi/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmeta.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

Get Programming with JavaScript Next New features of


ECMAScript 2015 2016 and beyond 1 / converted Edition Jd
Isaacks
https://ebookmeta.com/product/get-programming-with-javascript-next-
new-features-of-ecmascript-2015-2016-and-beyond-1-converted-edition-
jd-isaacks/
ebookmeta.com

Enhancing Adobe Acrobat Forms with JavaScript : Take Your


Forms to the Next Level! 1st Edition Jennifer Harder

https://ebookmeta.com/product/enhancing-adobe-acrobat-forms-with-
javascript-take-your-forms-to-the-next-level-1st-edition-jennifer-
harder/
ebookmeta.com

Functional Programming in JavaScript How to improve your


JavaScript programs using functional techniques 1st
Edition Luis Atencio
https://ebookmeta.com/product/functional-programming-in-javascript-
how-to-improve-your-javascript-programs-using-functional-
techniques-1st-edition-luis-atencio-2/
ebookmeta.com

The Truth about Forever and Lock and Key Sarah Dessen

https://ebookmeta.com/product/the-truth-about-forever-and-lock-and-
key-sarah-dessen/

ebookmeta.com
Biochemistry and Cell Biology of Ageing Part IV Clinical
Science 1st Edition J. Robin Harris

https://ebookmeta.com/product/biochemistry-and-cell-biology-of-ageing-
part-iv-clinical-science-1st-edition-j-robin-harris/

ebookmeta.com

Artificial Intelligence Systems and the Internet of Things


in the Digital Era Proceedings of EAMMIS 2021 Lecture
Notes in Networks and Systems 239 Abdalmuttaleb M.A
Musleh Al-Sartawi (Editor)
https://ebookmeta.com/product/artificial-intelligence-systems-and-the-
internet-of-things-in-the-digital-era-proceedings-of-
eammis-2021-lecture-notes-in-networks-and-systems-239-abdalmuttaleb-m-
a-musleh-al-sartawi-editor/
ebookmeta.com

Shared by the Aliens (Viraxian Mates #1) 1st Edition Ren


Hardwick [Hardwick

https://ebookmeta.com/product/shared-by-the-aliens-viraxian-
mates-1-1st-edition-ren-hardwick-hardwick/

ebookmeta.com

Data mining with SPSS Modeler : theory, exercises and


solutions Second Edition Tilo Wendler

https://ebookmeta.com/product/data-mining-with-spss-modeler-theory-
exercises-and-solutions-second-edition-tilo-wendler/

ebookmeta.com

HCI International 2022 Posters 24th International


Conference on Human Computer Interaction HCII 2022 Virtual
Event June 26 July 1 2022 Proceedings Part II Constantine
Stephanidis
https://ebookmeta.com/product/hci-international-2022-posters-24th-
international-conference-on-human-computer-interaction-
hcii-2022-virtual-event-june-26-july-1-2022-proceedings-part-ii-
constantine-stephanidis/
ebookmeta.com
Blood and Marrow Transplantation Long Term Management 2nd
Edition Bipin N Savani

https://ebookmeta.com/product/blood-and-marrow-transplantation-long-
term-management-2nd-edition-bipin-n-savani/

ebookmeta.com
JavaScript
Next
Your Complete Guide to the New Features
Introduced in JavaScript, Starting from
ES6 to ES9

Raju Gandhi
JavaScript Next
Your Complete Guide to the New
Features Introduced in JavaScript,
Starting from ES6 to ES9

Raju Gandhi
JavaScript Next
Raju Gandhi
Columbus, OH, USA

ISBN-13 (pbk): 978-1-4842-5393-9 ISBN-13 (electronic): 978-1-4842-5394-6


https://doi.org/10.1007/978-1-4842-5394-6

Copyright © 2019 by Raju Gandhi


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Louise Corrigan
Development Editor: James Markham
Coordinating Editor: Nancy Chen
Cover designed by eStudioCalamar
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484253939. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
IN MEMORIAM
My Baa
(1932–2018)
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� xi

About the Technical Reviewers����������������������������������������������������������������������������� xiii


Acknowledgments���������������������������������������������������������������������������������������������������xv

Introduction�����������������������������������������������������������������������������������������������������������xvii

Chapter 1: let and const — The New Declarations on the Block������������������������������ 1


The Dangers of Variable Scoping�������������������������������������������������������������������������������������������������� 1
let�������������������������������������������������������������������������������������������������������������������������������������������� 4
const�������������������������������������������������������������������������������������������������������������������������������������� 10
The Case for var in ES6 and Beyond������������������������������������������������������������������������������������������� 11
Summary������������������������������������������������������������������������������������������������������������������������������������ 12

Chapter 2: Lambdas with Arrow Functions������������������������������������������������������������ 13


Reevaluating the Verbosity of Function Definition���������������������������������������������������������������������� 13
Arrow Functions�������������������������������������������������������������������������������������������������������������������������� 16
Syntax������������������������������������������������������������������������������������������������������������������������������������ 17
Regular Functions Dynamically Set this�������������������������������������������������������������������������������� 19
Lexically Bound this��������������������������������������������������������������������������������������������������������������� 21
Other Caveats������������������������������������������������������������������������������������������������������������������������ 22
Use-cases������������������������������������������������������������������������������������������������������������������������������ 23
Summary������������������������������������������������������������������������������������������������������������������������������������ 26

Chapter 3: Effective Function Signatures with Default and Rest Parameters�������� 27


Unintentionally Obscuring Intent with Arguments���������������������������������������������������������������������� 27
Default Parameters��������������������������������������������������������������������������������������������������������������������� 29
Qualifying and Skipping Defaults������������������������������������������������������������������������������������������ 31
Usage Considerations������������������������������������������������������������������������������������������������������������ 32

v
Table of Contents

Rest Parameters������������������������������������������������������������������������������������������������������������������������� 33
The Argument Against arguments����������������������������������������������������������������������������������������� 33
The New ... Syntax����������������������������������������������������������������������������������������������������������������� 36
The rest of the Details (or is it the Details of rest?)��������������������������������������������������������������� 38
Summary������������������������������������������������������������������������������������������������������������������������������������ 39

Chapter 4: Divide and Conquer with Object and Array Destructuring�������������������� 41


Seeking Symmetry Between Structuring and Destructuring������������������������������������������������������ 42
Spread Operator for Arrays��������������������������������������������������������������������������������������������������������� 44
“Expanding” Upon the Nuances of the Spread Operator������������������������������������������������������� 45
Spread Operator for Objects������������������������������������������������������������������������������������������������������� 49
Object.defineProperties��������������������������������������������������������������������������������������������������������� 49
Spreading Objects����������������������������������������������������������������������������������������������������������������� 53
Destructuring������������������������������������������������������������������������������������������������������������������������������ 54
Array Destructuring��������������������������������������������������������������������������������������������������������������� 55
Object Destructuring������������������������������������������������������������������������������������������������������������� 61
Using Array and Object Destructuring in Combination���������������������������������������������������������� 64
Caveats��������������������������������������������������������������������������������������������������������������������������������������� 65
A Small Distinction���������������������������������������������������������������������������������������������������������������������� 65
Summary������������������������������������������������������������������������������������������������������������������������������������ 66

Chapter 5: Formatted Strings Using Template Strings������������������������������������������� 67


Introduction��������������������������������������������������������������������������������������������������������������������������������� 67
The Trouble with Forming Formed Strings���������������������������������������������������������������������������������� 68
Template literals������������������������������������������������������������������������������������������������������������������������� 70
Tagged Literals���������������������������������������������������������������������������������������������������������������������������� 73
Summary������������������������������������������������������������������������������������������������������������������������������������ 80

Chapter 6: Maps and Sets—The New Data-structures on the Block���������������������� 81


Why Objects are Not Enough������������������������������������������������������������������������������������������������������� 81
Maps������������������������������������������������������������������������������������������������������������������������������������������� 83
Caveats���������������������������������������������������������������������������������������������������������������������������������� 87
WeakMaps���������������������������������������������������������������������������������������������������������������������������������� 90

vi
Table of Contents

Sets��������������������������������������������������������������������������������������������������������������������������������������������� 92
Caveats���������������������������������������������������������������������������������������������������������������������������������� 95
WeakSets������������������������������������������������������������������������������������������������������������������������������������ 95
Summary������������������������������������������������������������������������������������������������������������������������������������ 98

Chapter 7: Bright Shiny Object(s) using Enhanced Object Literals������������������������� 99


The Limitations of the Object Literal����������������������������������������������������������������������������������������� 100
Getter/setters vs. Methods�������������������������������������������������������������������������������������������������� 100
Defining Computed Properties on Object Literals���������������������������������������������������������������� 102
Defining Object Properties Using Variables������������������������������������������������������������������������� 103
Enhanced Object Literal Syntax������������������������������������������������������������������������������������������������ 104
Method Definition Shorthand����������������������������������������������������������������������������������������������� 104
Computed Values����������������������������������������������������������������������������������������������������������������� 105
Property Value Shorthand���������������������������������������������������������������������������������������������������� 106
The Case of the Trailing Comma����������������������������������������������������������������������������������������������� 108
Summary���������������������������������������������������������������������������������������������������������������������������������� 109

Chapter 8: Hiding Behind Symbols����������������������������������������������������������������������� 111


Introduction������������������������������������������������������������������������������������������������������������������������������� 111
The Inability to Enforce a Contract�������������������������������������������������������������������������������������������� 111
Symbols to the Rescue������������������������������������������������������������������������������������������������������������� 114
Symbols and Switch-cases������������������������������������������������������������������������������������������������������� 117
Global Registry�������������������������������������������������������������������������������������������������������������������������� 119
Well-known Symbols���������������������������������������������������������������������������������������������������������������� 121
Not so Private���������������������������������������������������������������������������������������������������������������������������� 124
Summary���������������������������������������������������������������������������������������������������������������������������������� 125

Chapter 9: Iterable Sequences with Generators and Iterators����������������������������� 127


The Drawbacks of Lacking an Iteration Protocol���������������������������������������������������������������������� 128
The for-of Loop�������������������������������������������������������������������������������������������������������������������������� 131
Iterables and Iterators��������������������������������������������������������������������������������������������������������������� 133
Cleaning Up������������������������������������������������������������������������������������������������������������������������� 135
Other Benefits���������������������������������������������������������������������������������������������������������������������� 137

vii
Table of Contents

Generators�������������������������������������������������������������������������������������������������������������������������������� 138
Generators as Consumers��������������������������������������������������������������������������������������������������� 140
Cleaning Up������������������������������������������������������������������������������������������������������������������������� 141
Other Benefits���������������������������������������������������������������������������������������������������������������������� 143
Additional Syntactic Considerations������������������������������������������������������������������������������������ 144
Summary���������������������������������������������������������������������������������������������������������������������������������� 145

Chapter 10: Avoiding Callbacks with Promises���������������������������������������������������� 147


The Broken Promises of Promises�������������������������������������������������������������������������������������������� 147
Using Promises�������������������������������������������������������������������������������������������������������������������� 149
Using Promises�������������������������������������������������������������������������������������������������������������������� 151
All or Nothing����������������������������������������������������������������������������������������������������������������������� 153
Caveats�������������������������������������������������������������������������������������������������������������������������������� 155
The Benefits of a Native API������������������������������������������������������������������������������������������������ 156
Summary���������������������������������������������������������������������������������������������������������������������������������� 157

Chapter 11: Many of a Kind with Classes������������������������������������������������������������� 159


The Difficulties of Building Classes and Inheritance in JavaScript������������������������������������������� 159
Modeling Using Classes������������������������������������������������������������������������������������������������������������ 167
Caveats������������������������������������������������������������������������������������������������������������������������������������� 171
Summary���������������������������������������������������������������������������������������������������������������������������������� 171

Chapter 12: Namespacing Code Using Modules��������������������������������������������������� 173


The Lack of Namespacing in JavaScript����������������������������������������������������������������������������������� 173
How to Run Modularized JavaScript����������������������������������������������������������������������������������������� 176
Declaring Modules�������������������������������������������������������������������������������������������������������������������� 177
Aliasing Exports������������������������������������������������������������������������������������������������������������������� 182
A Quick Summary���������������������������������������������������������������������������������������������������������������� 182
Importing����������������������������������������������������������������������������������������������������������������������������������� 183
Aliasing Imports������������������������������������������������������������������������������������������������������������������� 186
Caveats and Implications���������������������������������������������������������������������������������������������������������� 188
Summary���������������������������������������������������������������������������������������������������������������������������������� 189

viii
Table of Contents

Chapter 13: Metamorphosis with Proxy and Reflect�������������������������������������������� 191


The Perils of Monkey-patching������������������������������������������������������������������������������������������������� 191
Metaprogramming with Proxy and Reflect������������������������������������������������������������������������������� 195
Enforcing Singletons����������������������������������������������������������������������������������������������������������������� 201
Building a DSL��������������������������������������������������������������������������������������������������������������������������� 203
Summary���������������������������������������������������������������������������������������������������������������������������������� 210

Chapter 14: Seemingly Imperative with async and await������������������������������������ 211


The Shortcomings of the Promise DSL������������������������������������������������������������������������������������� 211
async/await������������������������������������������������������������������������������������������������������������������������������� 214
Nuances and Caveats��������������������������������������������������������������������������������������������������������������� 220
Summary���������������������������������������������������������������������������������������������������������������������������������� 222

Chapter 15: Asynchronous Iterators and Generators—A Meeting of the Minds����223


The Impedance Mismatch Between Generators/Iterators and Asynchronous Operations�������� 223
Asynchronous Iterators������������������������������������������������������������������������������������������������������������� 227
Cleaning Up������������������������������������������������������������������������������������������������������������������������� 230
Being Imperative����������������������������������������������������������������������������������������������������������������� 231
Comingling with Synchronous Iterables������������������������������������������������������������������������������ 232
Generators�������������������������������������������������������������������������������������������������������������������������������� 233
Parity with Synchronous Iterators and Generators������������������������������������������������������������������� 234
Benefits������������������������������������������������������������������������������������������������������������������������������������� 235
Summary���������������������������������������������������������������������������������������������������������������������������������� 235

Index��������������������������������������������������������������������������������������������������������������������� 237

ix
About the Author
Raju Gandhi is a programmer with over 20 years of experience in the software industry.
He believes that the key to writing software users will cherish lies in having a keen
understanding of the problem, as well as intricate knowledge of the tools available to
solve those problems. He has been a core speaker on the No Fluff, Just Stuff symposium
series for over 7 years, along with other conferences like DevNexus, Connect.Tech, and
GIDS, India. In both his careers as a software developer and teacher, he believes the
key is to keep things simple, and in the words of Rich Hickey, “de-complected.” This
approach seems to scale well, for both maintainable software and happy audience
members.

xi
About the Technical Reviewers
Toby Jee is a software programmer currently located in Sydney, Australia. He loves
Linux and open source projects. He programs mainly in Java, JavaScript, Typescript, and
Python. In his spare time, Toby enjoys walkabouts, reading, and playing guitar.

Venkat Subramaniam is an internationally recognized polyglot programmer, author,


entrepreneur, and a regularly invited speaker at various international conferences. When
not hiking the mountains of Colorado, Venkat spends his time as a software consultant
for companies around the world, helping them adapt to various technologies and
sustainable agile practices.

xiii
Acknowledgments
Writing a book is a solitary pursuit. However, we sit on the shoulders of giants—past,
present, and future. This includes our families, teachers, and mentors who have
demonstrated to us the value of hard work and discipline, the technologists that came
before us who built what we sometimes take for granted, and finally, those who presently
work tirelessly to push the envelope and improve the status quo. I know that I have been
blessed to have had a chance to be influenced by many such greats—to every one of you
reading this book, you know who you are, and what you mean to me. Thank you.
I have had the privilege of speaking at many conferences, though one name in
particular stands out, namely, the No Fluff Just Stuff (NFJS) conference circuit. I am
indebted to Jay Zimmerman, the director of NFJS, for giving me a shot, as well as the
other speakers on the circuit as they continue to provide inspiration and share their
experiences. This book is the result of my having the chance to speak on this subject for a
while, but the meat of it comes from the interactions I have had with hundreds of smart,
talented developers around the world who made me question my own understanding of
the concepts, and forced me to dig deeper.
To Brian and Anne Sam-Bodden—my long-time employers, and more importantly,
friends—you have always had more faith in my capabilities than I did. You egged me
on to become a speaker and encouraged me to write a book. You provided me an
environment where I could experiment, and eventually flourish and thrive. I will always
remain indebted to you.
A special shout-out to my friend and mentor Dr. Venkat Subramaniam. Venkat is
someone I have come to lean on for everything between advice and camaraderie, both
personal and professional, and who, despite his frenetic schedule, always manages to
find the time to listen to me and provide a fair and unbiased perspective (often using
Dad jokes, but they get the job done).
To all the folks at Apress who made this book a reality, including Louise Corrigan,
Nancy Chen, and James Markham—thank you for your patience and hard work. It has
been a pleasure.
Despite the best efforts of all those involved in reviewing, editing, and proofreading
this book, any and all omissions and mistakes are mine, and mine alone.

xv
Acknowledgments

I would like to express my love and appreciation toward my significantly better half,
Michelle. She patiently took care of everything our lives threw at us, including taking
care of our boys, Mason and Micah, as I played recluse to work on this book. Of course,
I would be remiss if I did not mention our other two “children”—Buddy, our yorkie-­
poodle, and Skye, our labradoodle—for providing unflinching companionship and
endless amounts of entertainment. Special thanks to my parents and sisters, who will
never admit to it but have been the catalyst in forming me into who I am.
Last, but certainly not the least, I tip my hat off to you, the reader. Your attention
is a scarce resource, and I appreciate the time you will spend with this book. Happy
learnings.

xvi
Introduction
JavaScript is everywhere—it runs single-page applications on the client side, is used
on the server side (with technologies like Node.js), helps build desktop applications
with Electron,1 and can be used to work with single-board computers like Raspberry
Pi.2 JavaScript is even used to train machine-learning models in the browser using
technologies like TensorFlow.js.3 All this to say, JavaScript is (arguably) the most
deployed language in the world—every desktop and laptop and every phone with an
embedded browser can run JavaScript. As it stands today, JavaScript exhibits many of the
features that one would expect from a language with this large a footprint.
But that wasn’t always the case.
JavaScript has a long history, spanning 24 years at the time of this writing. In this
time, JavaScript went from being a scripting language used to animate web pages to
one that is being used everywhere, and for everything. JavaScript’s reputation, however,
preceded itself—it was deemed quirky and error-prone, and not all the criticisms
were without merit. And everyone, including the TC39,4 the central committee that is
responsible for evolving JavaScript, took notice.
In 2015, ES6 was announced, which introduced a slew of new features and syntactic
changes to the language. The aim was simple—to usher JavaScript into the modern
Web era—armed with the features that developers were vying for, and provide the basis
for future editions of the language.
The result? A language that aims to improve developer experience, with constructs
that seem familiar to developers coming in from other languages. Alongside, a yearly
cadence for releasing future editions was announced, ensuring that JavaScript continues
to evolve and mature.

1
h ttps://electronjs.org
2
www.raspberrypi.org/
3
www.tensorflow.org/js
4
https://tc39.es/

xvii
Introduction

Features like default parameters, support for variadic functions, destructuring


syntax, and fat-arrow functions make it easier to lean into JavaScript’s functional nature,
allowing for code that is concise and elegant. Simultaneously, the newly added class
syntax makes it possible to build inheritance hierarchies easily, allowing for library and
framework authors to provide the necessary “trellis” to hook into, and extend.
Asynchronous programming is a natural consequence of JavaScript’s inherent
design, and once again, the new additions to JavaScript make things easier. Promises are
now a native API, opening the door for a whole new level of abstractions, that we, the
developers, can build on. Two such abstractions are async/await, which use promises
and help make writing asynchronous code seem almost imperative.
And there is much more! All put together, JavaScript today feels like a very different
language—one that acts and behaves like other languages that developers might be
used to.
This book aims to introduce you to all of these features, endeavoring to provide a
nuanced view of the “what” and the “why” for every inclusion. However, we cannot learn
without doing—so this book provides a slew of examples, each one catered to highlight
a specific feature. So, let’s put our developer hats on, fire up our editors, and write some
code.
Ready? Set? Go!

Who should read this book


This book is directed toward programmers, developers, technical leads, architects,
programming hobbyists, or anyone interested in learning about how JavaScript has
evolved over the past 5 years. If you are someone who dreads JavaScript development
because you have been burnt one too many times by the language, then perhaps this
book will demonstrate how the language has been transformed to be more familiar
(to programmers comfortable with other languages) and less idiosyncratic.

What you’ll find in this book


This book aims to be a comprehensive resource on all the enhancements that were
introduced in Ecmascript (ES) 6, 7, 8, and 9. Every chapter starts with highlighting a
deficiency or defect in the language, and its implications. It then introduces a new feature
or addition to the language, and how the change addresses the specific problem area.

xviii
Introduction

This book does not aim to introduce new features chronologically (starting with
edition 6 all the way through 9); rather, I aim to collate features from multiple editions, as
long as they logically “reside” together. However, I do highlight which edition the feature
was introduced.
Many technical books give you a play-by-play, chapter-by-chapter breakdown of
what you are to find in the book. Truth be told, I have always found myself skipping over
the listing, preferring to stick to the table of contents, or heading straight for the index to
find what I am looking for. Consequently, I am going to save myself a few keystrokes, and
you a little time. I do hope you will understand, and perhaps forgive this omission.

What you won’t find in this book


This book does not intend to be a comprehensive resource to programming, or
JavaScript, the language. It assumes that you, the reader, have a background in
programming and a certain familiarity with the language. However, there are parts to the
language that many of us may not have explored in the past, and for those aspects, I do
provide a richer discourse if I deem it necessary.
JavaScript also regularly sees modifications, additions, and the occasional
deprecation to existing APIs, and this trend continues in the newer editions of the
language. Again, this book does not cover any of these; rather, it focuses on syntactic
enhancements to the language.
Finally, there exist several options to run modern JavaScript. These include
transpilers like Babel.5 This book makes no attempt to cover how to use any such tooling,
or document the associated configurations.

How to use this book


The examples in this book are written with two mandates—they should be bite-sized
and should build on previously learned material. In this regard, I believe I have (mostly)
succeeded. You can find all the examples in this book in our online repository located
at https://github.com/Apress/javascript-next. Feel free to clone or download this
repository, and then follow the instructions on usage in the README contained therein.

5
https://babeljs.io/

xix
Introduction

Alternatively, the path of least resistance is to simply use your browser console. Most
modern browsers, like Chrome6 and Firefox,7 come equipped with a console.8 You can
simply copy and paste the examples found in this book in the console and experiment to
your heart’s desire.
Personally, I prefer to experiment in my text editor. If you are anything like me, and
prefer using a familiar medium, you will need Node.js installed. Follow the instructions
on their web site9 to install Node. If you already have Node installed and do not wish
to introduce a conflict, investigate “Node Version Manager”10 or “nvm-windows”11 that
allow you to install multiple versions of Node simultaneously.
Once Node is installed, create a scratch directory anywhere on your computer and
navigate to it. Then create a new file named hello-world.js with the following contents:

console.log('Hello JavaScript!');

Switch to the terminal, navigate to your scratch directory, and execute the following
command:

node hello-world.js

You should see the following output:

Hello JavaScript!

You can run all the examples in this book in this manner. This modus operandi will
serve you well, except for Chapter 12, where we talk about modules, wherein I provide
additional instructions.
Most editors allow for a way to execute code from within the editor itself using
extensions, plugins, or via a build system. Be sure to read the documentation of your
favorite editor to see how to enable this to allow for a quick feedback loop. Regardless of
the mechanism you employ, ensure that you are always using the correct version of Node.
Let’s write some modern JavaScript!

6
w ww.google.com/chrome/
7
www.mozilla.org/en-US/firefox/
8
In Google Chrome this can be found under View ➤ Developer ➤ JavaScript Console. In Mozilla
Firefox use Tools ➤ Web Developer ➤ Web Console.
9
https://nodejs.org/en/
10
https://github.com/nvm-sh/nvm
11
https://github.com/coreybutler/nvm-windows

xx
CHAPTER 1

let and const — The New


Declarations on the Block
The use of variables in JavaScript, like in many other languages, is pervasive.
Assignments, arguments to function calls, and results of computations; variables are
everywhere. Simply put, they allow us to store the “state” of a program.
JavaScript only offers one mechanism to declare variables, the ubiquitous var.
However, as we will see in this chapter, var presents us with several semantic potholes.
We will also see how the introduction of two new keywords, namely let and const, to
declare variables helps us avoid subtle bugs, and often unintended side effects, as well as
makes the intent of our code clearer.
By the end of this chapter, we will have seen why let and const are not only the
preferred way to declare and initialize variables, but also have a strong argument in
favor of deprecating var. We will also learn how to refactor our existing code to reap the
benefits that let and const offer and recognize the best use-case for each.

The Dangers of Variable Scoping


JavaScript supports both statements and expressions, and typically, to capture the
value that results from an evaluation, we use variables. There are times though when a
variable, despite its name, isn’t a variable, but designated to be a constant. That is, once
set, we intend for the value of the variable to not change over time.
However, up until now, JavaScript provided us with only one keyword, namely
var, to initialize variables, regardless of whether they were to see their values change
(consider the index in a for loop), or be constant. For the latter, developers resorted to
a naming convention, typically upper-snake-case, like SOUTH_WEST, alluding that it be
treated like a constant, with no runtime support from the language.

1
© Raju Gandhi 2019
R. Gandhi, JavaScript Next, https://doi.org/10.1007/978-1-4842-5394-6_1
Chapter 1 let and const — The New Declarations on the Block

Thus, not only was the use of var overloaded, to add insult to the injury, it presented
us with a few stumbling blocks. Variables declared with var are automatically hoisted to
the top of the current scope. Furthermore, redeclaring two vars with the same name in
the same scope does not throw an error. Combine these two, and the result can prove to
be rather insidious as demonstrated here:

function insidious() {
  var functionScoped = 'Outer declaration'; ①
  if (true) {
    var functionScoped = 'Inner declaration'; ②
  }
  console.log(functionScoped); ③
  return functionScoped;
}
// prints 'Inner declaration'
insidious();

① A top level variable declaration

② Seemingly “shadows” the outer declaration

③ Turns out, the two variables are one and the same!

One may assume that the inner nested functionScoped is scoped within the if block,
which is not true! In fact, the second declaration of functionScoped is a no-op. However,
this does not prevent JavaScript from declaring the variable once (at the top) and then
reassigning the value of the variable further down, as reflected in the output. To avoid
any confusion, JavaScript developers tend to declare all the variables that are to be used
within a function upfront.
This notion of vars not being block scoped is certainly surprising, since many
languages scope variables lexically. That is, the variable in these languages is scoped
textually within the enclosing parentheses, and not visible outside of the scope created
by the block. This might lean one to believe that vars are scoped, when in reality they are
not, and can have inexplicable outcomes. Consider the following example:

function simulateDom() {
  var pseudoDom = {
    button1: {},

2
Chapter 1 let and const — The New Declarations on the Block

    button2: {},
    button3: {},
  }; ①

  for (var i = 1; i <= 3; i++) {


    var element = pseudoDom['button' + i];
    element.click = function () {
      return 'Item ' + i + ' is clicked.'; ②
    };
  }

  console.log(pseudoDom.button1.click());
  console.log(pseudoDom.button2.click());
  console.log(pseudoDom.button3.click()); ③
  return pseudoDom;
}
// prints 'Item 4 is clicked.' 3 times
simulateDom();

① Simulate the DOM with three buttons

② For each button, add a click handler

③ All print Item 4 is clicked

Since the variable i is hoisted outside the for loop, and is not local to the for loop
itself, every click handler “sees” the same i. At the end of the loop, the value of i is
predictably 4, which is reported on any button click.
Summarizing, any var declared within a function is scoped to that function, even if it
is defined within a block.

WHAT ABOUT STRICT MODE?

ES5 introduced strict mode as an opt-in feature as a way to restrict some JavaScript
behavior. This was done in part to make the transition to future versions of JavaScript easier,
by changing the semantics of the code and in particular disallowing some behaviors. While
strict mode does help prevent some rather nasty errors from occurring, for example,
inadvertently declaring “global” variables (variables declared within functions without the var
keyword), it does not change the scoping rules that we have discussed so far.
3
Chapter 1 let and const — The New Declarations on the Block

Using strict mode with ES5 code is highly encouraged, and as we embark on a journey to
understand and adopt ES6+, it would be prudent to incrementally introduce strict mode in
our existing scripts. This will certainly make converting them to ES6 easier. The documentation
for strict mode is available at https://developer.mozilla.org/en-US/docs/Web/
JavaScript/Reference/Strict_mode.

In summary, if all the above makes your head spin, then you are not alone.
Navigating JavaScripts scoping rules is hard enough; combining that with var-­iable
hoisting further muddies the waters. In order to address some of the concerns
surrounding vars, ES6 activated1 let. let addresses many of the scoping deficits that
come with var as we will see in the following sections.
Why let instead of simply fixing var you might ask. Well, we wouldn’t want to go
about breaking the Internet, would we?

let
As you might have surmised, most of the confusion around vars exist because vars
do not respect “block” scope. A block in JavaScript is a way to collect one or more
statements; in other words, they allow us to create a compound statement. Blocks are
delimited by a pair of curly brackets, and if you are thinking, “Wait. Looping constructs
(like for and while) and conditional statements (like if and else) use curly brackets.
Are those blocks?” then you are right.
Blocks do not introduce scope. However, ES6 introduces block scope for variables
that are defined using the let keyword. A variable defined with the let keyword will be
scoped within the closest enclosing block. In other words, variables defined with the let
keyword are lexically scoped to the closest enclosing block:

function letFunction() {
  // console.log('Before defining block', scopedLet); ①

  if (true) {
    let scopedLet = 'I am scoped within a block!'; ②
  }

1
I say activated vs. introduced because let was always a reserved keyword in JavaScript.

4
Chapter 1 let and const — The New Declarations on the Block

  // console.log('After defining block', scopedVar); ③


}

// invoke it
letFunction();

① A variable declared within a block cannot be referenced


outside of the block

② A variable declared with the let syntax

③ Like before, the variable is not visible outside of the scope


defined by the if block

We can breathe a sigh of relief! Variables declared with the let keyword seem to
follow the rules of scoping that you are used to coming from other languages, and they
do reduce the contextual overhead associated with vars.
Many of the issues (and potential bugs) that arise from the broad-reaching var scope
can be averted by using let instead. Let us revisit our earlier example of a simulated
DOM and see the effect of using let:

function simulateDom() {
  let pseudoDom = {
    button1: {},
    button2: {},
    button3: {},
  };

  for (let i = 1; i <= 3; i++) { ①


    let element = pseudoDom['button' + i];
    element.click = function() {
      return 'Item ' + i + ' is clicked.'; ②
    };
  }

  console.log(pseudoDom.button1.click());
  console.log(pseudoDom.button2.click());
  console.log(pseudoDom.button3.click()); ③

5
Chapter 1 let and const — The New Declarations on the Block

  return pseudoDom;
}
// prints 'Item 1 is clicked.', 'Item 2 is clicked.', 'Item 3 is clicked.'
simulateDom();

① i is local to the for loop

② Since i is a local variable, each handler sees the correct value of i

③ Predictably all the click handlers report the correct message

As we can see, variables declared with let do respect the scope of the enclosing
block, thus making the code a lot easier to reason about.
Although let does simplify the scoping rules for variables, they too come with a few
caveats, as we will see in the following section.

Let Variables are Hoisted


It turns out that variables declared with let do get hoisted to the top of their enclosing
block. However, an attempt to reference such a variable before it is defined will result in
an error. This is a departure from the behavior of var, where we can indeed “see” the
variable prior to its definition (except that it evaluates to undefined).
Consider the following example:

var foo;
{ ①
  foo = function() {
    console.log('I am', bar); ②
  };

  let bar = 'Bar'; ③


  // invoke it
  // foo(); ④
}

① Introduce an artificial block


② foo references bar before it is declared

③ We define bar

④ We then invoke foo

6
Chapter 1 let and const — The New Declarations on the Block

We can surmise what happened here. The declaration of bar moved to the top of the
enclosing block, allowing it to be used prior to its declaration.
In and of itself, this feature (?) might not seem too troublesome. However, there is
another constraint that let presents us with. That is, you are not allowed to define two
variables in the same scope with the same name (this again is a departure from the
behavior of vars). JavaScript will throw a SyntaxError in that scenario.
Perhaps the following example will clarify things:

function determineFavoriteDrink(profession) {
  switch (profession) {
    case 'Programmer':
      let drink = 'coffee'; ①
      break
    case 'Yoga instructor':
      let drink = 'tea'; ②
      break;
    default:
      let drink = 'water'; ③
      break;
  }
  return drink;
}
// results in a 'SyntaxError'
console.log(determineFavoriteDrink('Programmer'));

① Introduce a variable

② This will throw an error!

③ This too will throw an error

Invocation of the function results in a SyntaxError! The reason is that let


simultaneously hoists and prevents redefinition of the same variable. This example
demonstrates a cautionary tale as we start to migrate our code from using var to let—
we cannot simply replace var with let. var may have permitted us to get away with
sloppy code; however, let correctly tightens things up, and we must exercise caution to
ensure that all is well after refactoring. However, this is also to our benefit—let exhibits
reasonable semantics, and this alone should prove sufficient for us to never use var again.

7
Chapter 1 let and const — The New Declarations on the Block

No More IEFEs


JavaScript’s lack of scoping for vars often led to the use of creative solutions to create
private variables. One of these solutions was the use of an “Immediately Executing
Function Expression” or IEFE. Let us take a before and after version of the same
functionality, one using vars with an IEFE and one using let with blocks:

const counter = (function createCounter() { ①


  var steps = 0; ②
  function increment() {
    steps++;
  }
  function getCount() {
    return steps;
  }

  return {
    increment: increment,
    getCount: getCount,
  }; ③
}());
// use it
// console.log(steps); ④
counter.increment(); ⑤
console.assert(counter.getCount() === 1); ⑥

① Introduce artificial block by creating an anonymous function

② This var will be scoped within the declared function

③ Expose a public API by return-ing an object

④ This will result in a ReferenceError

⑤ You can use the public API

⑥ Invoke the public getter


With let we no longer have to use an IEFE because we can simply surround our code
with curly brackets to create an enclosing scope!

let counter;

8
Chapter 1 let and const — The New Declarations on the Block

{ ①
  let steps = 0; ②
  let increment = function () { ③
    console.log('increment');
    steps++;
  };
  let getCount = function () {
    return steps;
  };
  counter = {
    increment: increment,
    getCount: getCount,
  }; ④
}
// use it
// console.log(steps); ⑤
counter.increment(); ⑥
console.assert(counter.getCount() === 1); ⑦

① Introduce artificial block using curly brackets

② This variable is automatically scoped within the block

③ Convert a function statement to a function expression

④ Simply assign a variable to be available outside of the block


⑤ We still cannot “see” the let-ted variable

⑥ But you can use the public API

⑦ Invoke the public getter

Both these examples attempt to limit the visibility of the increment and getCount
functions. However, leveraging let allows us to eliminate all the ceremony involved with
using vars.

9
Chapter 1 let and const — The New Declarations on the Block

const
ES6 activates another keyword, namely const. As the name suggests, this will define a
constant. In other words, it defines a variable whose value cannot be changed once they
have been declared.
Other than the fact that consts cannot be reassigned, everything we have discussed
so far about let applies to const as well—they have block scope, and will be hoisted to
the top of the enclosing block, and we cannot declare two consts with the same name in
the same scope.
It is important for us to bear in mind that it is the binding of a const variable that
cannot be changed. This has significance because JavaScript objects (such as Object and
Array) are inherently mutable. Which is to say, if a const were assigned a reference to an
object, it is that reference that cannot be changed; the object itself could change, and the
const would see that change. Perhaps this is easier seen in code.

const VALUE_REFERENCE = 'This cannot be re-assigned'; ①


const ARRAY_REFERENCE = [ 'I', 'am', 'mutable' ]; ②

// attempt re-assignment
// VALUE_REFERENCE = false ③
// ARRAY_REFERENCE = {}

// Mutate the array object


ARRAY_REFERENCE.push('!'); ④
// prints [ 'I', 'am', 'mutable', '!' ]
console.log(ARRAY_REFERENCE);

① A value reference

② An object reference

③ Reassignment fails with a TypeError

④ We can however mutate the referenced object

10
Chapter 1 let and const — The New Declarations on the Block

WHAT ABOUT IMMUTABLE OBJECTS?

const constraints itself to make the binding of a variable immutable. If we want to


make an object type in JavaScript immutable, we should consider “freezing” it with say
Object.freeze, or consider using a library like Immutable.js.2

Another point of note is declaring a const with no initial value also results in a
SyntaxError. Essentially declaring such a const will permanently assign the constant
to undefined, which is redundant considering JavaScript already has the undefined
keyword for such situations.
Finally, the JavaScript community has converged around the convention of naming
constant variables using upper case with underscores. This makes it easier to identify
constants within the codebase.

The Case for var in ES6 and Beyond


We now know that we can use let anywhere we use var and get some added benefits
like clearer scoping rules. consts allow us to declaratively define immutable bindings.
Considering we have block scope, we can move away from ceremony like IEFEs for
encapsulation. All this to say that for any code written using ES6+, we should not be
using vars anymore.
I suggest we take this a step further—we should be finding ways to write our code
in a manner that uses const more than let. Reassigning variables makes it hard to
read, understand, and reason about our code. Given a choice between let and const,
I highly encourage to pick the latter, and you will soon realize how clearer and cleaner
the result is.
Tools like ESLint can be configured3 to error when linting ES6+ code, and it is highly
recommended that we do so. var will forever remain a part of JavaScript’s history;
however, it is time for us to move on to using only let and const in our codebases.

2
h ttps://immutable-js.github.io/immutable-js/
3
https://eslint.org/docs/rules/no-var

11
Chapter 1 let and const — The New Declarations on the Block

Summary
ES6 gives us several new constructs to declare and use variables in our code. let and
const allow us to use a declaration style which are more in tune with what we may be
used to in other languages. Their scoping rules permit easier reasoning of the code,
preventing bugs that often get introduced due to vars. As browser vendors offer us better
support for ES6 and beyond, it behooves us to embrace these new constructs. Going
forward, there is no reason to favor var anymore. let and const give us everything we
need, with the appropriate checks baked into the runtime. We should leverage linting
tools that allow us to enforce this, both at development time and during our continuous
builds.
In the next chapter, we will see another revolutionary change that landed in ES6,
namely a new syntax to define functions.

12
CHAPTER 2

Lambdas with Arrow


Functions
Functions are used everywhere in JavaScript. A face-lift to make their syntax succinct,
and consequently easier to use and understand, was long overdue.
JavaScript is, at its core, a functional programming language. It supports functions as
first-class citizens, in that they are like any other type in the language. Functions can be
assigned to variables, supplied as arguments to other functions, and be return-­ed
from functions just like we would any other type in JavaScript. JavaScript is also single-
threaded. Well-designed APIs and libraries that involve long-running operations
work asynchronously, typically accepting a callback which is to be invoked when the
(asynchronous) task is complete. These callbacks happen to be functions as well. Finally,
the mechanism to define methods on objects also happen to be functions.
In this chapter we will get acclimated with a new syntax for function expressions, also
referred to as “arrow” functions that was introduced in ES6. We will see how our code can
be made eloquent with shorter syntax, thereby allowing us to express our intent clearly.
Our discussion will include how arrow functions’ behaviors differ from regular functions,
allowing us to discern when best to use arrow functions. By the end of this chapter, you
will be raring to return to your codebase knowing that you can confidently eliminate any
unnecessary verbosity, leaving behind, well …​let’s just call it poetry, shall we?

Reevaluating the Verbosity of Function Definition


In ES5 we can define functions using several constructs, the two primary mechanisms
being function statements and expressions. The focus of this chapter will be on function
expressions; however, it behooves me to elaborate on the syntactical difference between
the two. Consider the following function statement.

13
© Raju Gandhi 2019
R. Gandhi, JavaScript Next, https://doi.org/10.1007/978-1-4842-5394-6_2
Exploring the Variety of Random
Documents with Different Content
last time I saw her—when was it? Monday. Yes, she struck me as
looking thoroughly depressed.’
‘Oh, but surely you were wrong . . .’ interrupted Stephen.
‘No, I’m perfectly sure I was right,’ he insisted. Then he said: ‘I’m
going to take a big risk—I’m going to take the risk of losing your
friendship.’
His voice was so genuinely regretful, that Stephen must ask him:
‘Well—what is it, Brockett?’
‘You, my dear. You’re not playing fair with that girl; the life she’s
leading would depress a mother abbess. It’s enough to give anybody
the hump, and it’s going to give Mary neurasthenia!’
‘What on earth do you mean?’
‘Don’t get ratty and I’ll tell you. Look here, I’m not going to pretend
any more. Of course we all know that you two are lovers. You’re
gradually becoming a kind of legend—all’s well lost for love, and that
sort of thing. . . . But Mary’s too young to become a legend; and so are
you, my dear, for that matter. But you’ve got your work, whereas
Mary’s got nothing—not a soul does that miserable kid know in Paris.
Don’t please interrupt, I’ve not nearly finished; I positively must and will
have my say out! You and she have decided to make a ménage—as
far as I can see it’s as bad as marriage! But if you were a man it would
be rather different; you’d have dozens of friends as a matter of course.
Mary might even be going to have an infant. Oh, for God’s sake,
Stephen, do stop looking shocked. Mary’s a perfectly normal young
woman; she can’t live by love alone, that’s all rot—especially as I
shrewdly suspect that when you’re working the diet’s pretty meagre.
For heaven’s sake let her go about a bit! Why on earth don’t you take
her to Valérie Seymour’s? At Valérie’s place she’d meet lots of people;
and I ask you, what harm could it possibly do? You shun your own ilk
as though they were the devil! Mary needs friends awfully badly, and
she needs a certain amount of amusement. But be a bit careful of the
so-called normal.’ And now Brockett’s voice grew aggressive and
bitter. ‘I wouldn’t go trying to force them to be friends—I’m not thinking
so much of you now as of Mary; she’s young and the young are easily
bruised. . . .’
He was perfectly sincere. He was trying to be helpful, spurred on
by his curious affection for Stephen. At the moment he felt very friendly
and anxious; there was nothing of the cynic left in him—at the
moment. He was honestly advising according to his lights—perhaps
the only lights that the world had left him.
And Stephen could find very little to say. She was sick of denials
and subterfuges, sick of tacit lies which outraged her own instincts and
which seemed like insults thrust upon Mary; so she left Brockett’s
bolder statements unchallenged. As for the rest, she hedged a little,
still vaguely mistrustful of Valérie Seymour. Yet she knew quite well
that Brockett had been right—life these days must often be lonely for
Mary. Why had she never thought of this before? She cursed herself
for her lack of perception.
Then Brockett tactfully changed the subject; he was far too wise
not to know when to stop. So now he told her about his new play,
which for him was a very unusual proceeding. And as he talked on
there came over Stephen a queer sense of relief at the thought that he
knew. . . . Yes, she actually felt a sense of relief because this man
knew of her relations with Mary; because there was no longer any
need to behave as if those relations were shameful—at all events in
the presence of Brockett. The world had at last found a chink in her
armour.

‘We must go and see Valérie Seymour one day,’ Stephen remarked
quite casually that evening. ‘She’s a very well-known woman in Paris. I
believe she gives rather jolly parties. I think it’s about time you had a
few friends.’
‘Oh, what fun! Yes, do let’s—I’d love it!’ exclaimed Mary.
Stephen thought that her voice sounded pleased and excited, and
in spite of herself she sighed a little. But after all nothing really
mattered except that Mary should keep well and happy. She would
certainly take her to Valérie Seymour’s—why not? She had probably
been very foolish. Selfish too, sacrificing the girl to her cranks—
‘Darling, of course we’ll go,’ she said quickly. ‘I expect we’ll find it
awfully amusing.’

Three days later, Valérie, having seen Brockett, wrote a short but
cordial invitation: ‘Do come in on Wednesday if you possibly can—I
mean both of you, of course. Brockett’s promised to come, and one or
two other interesting people. I’m so looking forward to renewing our
acquaintance after all this long time, and to meeting Miss Llewellyn.
But why have you never been to see me? I don’t think that was very
friendly of you! However, you can make up for past neglect by coming
to my little party on Wednesday. . . .’
Stephen tossed the letter across to Mary. ‘There you are!’
‘How ripping—but will you go?’
‘Do you want to?’
‘Yes, of course. Only what about your work?’
‘It will keep all right for one afternoon.’
‘Are you sure?’
Stephen smiled. ‘Yes, I’m quite sure, darling.’

CHAPTER 44

V alérie’s rooms were already crowded when Stephen and Mary


arrived at her reception, so crowded that at first they could not see
their hostess and must stand rather awkwardly near the door—they
had not been announced; one never was for some reason, when one
went to Valérie Seymour’s. People looked at Stephen curiously; her
height, her clothes, the scar on her face, had immediately riveted their
attention.
‘Quel type!’ murmured Dupont the sculptor to his neighbour, and
promptly decided that he wished to model Stephen. ‘It’s a wonderful
head; I adore the strong throat. And the mouth—is it chaste, is it
ardent? I wonder. How would one model that intriguing mouth?’ Then
being Dupont, to whom all things were allowed for the sake of his art,
he moved a step nearer and stared with embarrassing admiration,
combing his greyish beard with his fingers.
His neighbour, who was also his latest mistress, a small fair-haired
girl of a doll-like beauty, shrugged her shoulders. ‘I am not very
pleased with you, Dupont, your taste is becoming peculiar, mon ami—
and yet you are still sufficiently virile. . . .’
He laughed. ‘Be tranquil, my little hen, I am not proposing to give
you a rival.’ Then he started to tease. ‘But what about you? I dislike
the small horns that are covered with moss, even although they are no
bigger than thimbles. They are irritating, those mossy horns, and
exceedingly painful when they start to grow—like wisdom teeth, only
even more foolish. Ah, yes, I too have my recollections. What is sauce
for the gander is sauce for the goose, as the English say—such a
practical people!’
‘You are dreaming, mon pauvre bougre,’ snapped the lady.
And now Valérie was making her way to the door. ‘Miss Gordon!
I’m most awfully glad to see you and Miss Llewellyn. Have you had
any tea? No, of course not, I’m an abominable hostess! Come along to
the table—where’s that useless Brockett? Oh, here he is. Brockett,
please be a man and get Miss Llewellyn and Miss Gordon some tea.’
Brockett sighed. ‘You go first then, Stephen darling, you’re so much
more efficient than I am.’ And he laid a soft, white hand on her
shoulder, thrusting her gently but firmly forward. When they reached
the buffet, he calmly stood still. ‘Do get me an ice—vanilla?’ he
murmured.
Every one seemed to know every one else, the atmosphere was
familiar and easy. People hailed each other like intimate friends, and
quite soon they were being charming to Stephen, and equally
charming and kind to Mary.
Valérie was introducing her new guests with tactful allusions to
Stephen’s talent: ‘This is Stephen Gordon-you know, the author; and
Miss Llewellyn.’
Her manner was natural, and yet Stephen could not get rid of the
feeling that every one knew about her and Mary, or that if they did not
actually know, they guessed, and were eager to show themselves
friendly.
She thought: ‘Well, why not? I’m sick of lying.’
The erstwhile resentment that she had felt towards Valérie
Seymour was fading completely. So pleasant it was to be made to feel
welcome by all these clever and interesting people—and clever they
were there was no denying; in Valérie’s salon the percentage of brains
was generally well above the average. For together with those who
themselves being normal, had long put intellects above bodies, were
writers, painters, musicians and scholars, men and women who, set
apart from their birth, had determined to hack out a niche in existence.
Many of them had already arrived, while some were still rather
painfully hacking; not a few would fall by the way, it is true, but as they
fell others would take their places. Over the bodies of prostrate
comrades those others must fall in their turn or go on hacking—for
them there was no compromise with life, they were lashed by the whip
of self-preservation. There was Pat who had lost her Arabella to the
golden charms of Grigg and the Lido. Pat, who, originally hailing from
Boston, still vaguely suggested a new England schoolmarm. Pat,
whose libido apart from the flesh, flowed into entomological channels
—one had to look twice to discern that her ankles were too strong and
too heavy for those of a female.
There was Jamie, very much more pronounced; Jamie who had
come to Paris from the Highlands; a trifle unhinged because of the
music that besieged her soul and fought for expression through her
stiff and scholarly compositions. Loose limbed, raw boned and short
sighted she was; and since she could seldom afford new glasses, her
eyes were red-rimmed and strained in expression, and she poked her
head badly, for ever peering. Her tow-coloured mop was bobbed by
her friend, the fringe being only too often uneven.
There was Wanda, the struggling Polish painter; dark for a Pole
with her short, stiff black hair, and her dusky skin, and her colourless
lips; yet withal not unattractive, this Wanda. She had wonderful eyes
that held fire in their depths, hell-fire at times, if she had been drinking;
but at other times a more gentle flame, although never one that it was
safe to play with. Wanda saw largely. All that she envisaged was
immense, her pictures, her passions, her remorses. She craved with a
well-nigh insatiable craving, she feared with a well-nigh intolerable
terror—not the devil, she was brave with him when in her cups, but
God in the person of Christ the Redeemer. Like a whipped cur she
crawled to the foot of the Cross, without courage, without faith, without
hope of mercy. Outraged by her body she must ruthlessly scourge it—
no good, the lust of the eye would betray her. Seeing she desired and
desiring she drank, seeking to drown one lust in another. And then she
would stand up before her tall easel, swaying a little but with hand
always steady. The brandy went into her legs, not her hands; her
hands would remain disconcertingly steady. She would start some
gigantic and heart-broken daub, struggling to lose herself in her
picture, struggling to ease the ache of her passion by smearing the
placid white face of the canvas with ungainly yet strangely arresting
forms—according to Dupont, Wanda had genius. Neither eating nor
sleeping she would grow very thin, so that everybody would know
what had happened. They had seen it before, oh, but many times, and
therefore for them the tragedy was lessened.
‘Wanda’s off again!’ some one might say with a grin. ‘She was tight
this morning; who is it this time?’
But Valérie, who hated drink like the plague, would grow angry;
outraged she would feel by this Wanda.
There was Hortense, Comtesse de Kerguelen; dignified and
reserved, a very great lady, of a calm and rather old-fashioned beauty.
When Valérie introduced her to Stephen, Stephen quite suddenly
thought of Morton. And yet she had left all for Valérie Seymour;
husband, children and home had she left; facing scandal, opprobrium,
persecution. Greater than all these most vital things had been this
woman’s love for Valérie Seymour. An enigma she seemed, much in
need of explaining. And now in the place of that outlawed love had
come friendship; they were close friends, these one-time lovers.
There was Margaret Roland, the poetess, a woman whose work
was alive with talent. The staunchest of allies, the most fickle of lovers,
she seemed likely enough to end up in the work-house, with her
generous financial apologies which at moments made pretty large
holes in her savings. It was almost impossible not to like her, since her
only fault lay in being too earnest; every fresh love affair was the last
while it lasted, though of course this was apt to be rather misleading. A
costly business in money and tears; she genuinely suffered in heart as
in pocket. There was nothing arresting in Margaret’s appearance,
sometimes she dressed well, sometimes she dressed badly, according
to the influence of the moment. But she always wore ultra feminine
shoes, and frequently bought model gowns when in Paris. One might
have said quite a womanly woman, unless the trained ear had been
rendered suspicious by her voice which had something peculiar about
it. It was like a boy’s voice on the verge of breaking.
And then there was Brockett with his soft, white hands; and several
others there were, very like him. There was also Adolphe Blanc, the
designer—a master of colour whose primitive tints had practically
revolutionized taste, bringing back to the eye the joy of the simple.
Blanc stood in a little niche by himself, which at times must surely
have been very lonely. A quiet, tawny man with the eyes of the
Hebrew, in his youth he had been very deeply afflicted. He had spent
his days going from doctor to doctor: ‘What am I?’ They had told him,
pocketing their fees; not a few had unctuously set out to cure him.
Cure him, good God! There was no cure for Blanc, he was, of all men,
the most normal abnormal. He had known revolt, renouncing his God;
he had known despair, the despair of the godless; he had known wild
moments of dissipation; he had known long months of acute self-
abasement. And then he had suddenly found his soul, and that finding
had brought with it resignation, so that now he could stand in a niche
by himself, a pitiful spectator of what, to him, often seemed a
bewildering scheme of creation. For a living he designed many
beautiful things—furniture, costumes and scenery for ballets, even
women’s gowns if the mood was upon him, but this he did for a
physical living. To keep life in his desolate, long-suffering soul, he had
stored his mind with much profound learning. So now many poor
devils went to him for advice, which he never refused though he gave
it sadly. It was always the same: ‘Do the best you can, no man can do
more—but never stop fighting. For us there is no sin so great as
despair, and perhaps no virtue so vital as courage.’ Yes, indeed, to this
gentle and learned Jew went many a poor baptized Christian devil.
And such people frequented Valérie Seymour’s, men and women
who must carry God’s mark on their foreheads. For Valérie, placid and
self-assured, created an atmosphere of courage; every one felt very
normal and brave when they gathered together at Valérie Seymour’s.
There she was, this charming and cultured woman, a kind of
lighthouse in a storm-swept ocean. The waves had lashed round her
feet in vain; winds had howled; clouds had spued forth their hail and
their lightning; torrents had deluged but had not destroyed her. The
storms, gathering force, broke and drifted away, leaving behind them
the shipwrecked, the drowning. But when they looked up, the poor
spluttering victims, why what should they see but Valérie Seymour!
Then a few would strike boldly out for the shore, at the sight of this
indestructible creature.
She did nothing, and at all times said very little, feeling no urge
towards philanthropy. But this much she gave to her brethren, the
freedom of her salon, the protection of her friendship; if it eased them
to come to her monthly gatherings they were always welcome
provided they were sober. Drink and drugs she abhorred because they
were ugly—one drank tea, iced coffee, sirops and orangeade in that
celebrated flat on the Quai Voltaire.
Oh, yes, a very strange company indeed if one analysed it for this
or that stigma. Why, the grades were so numerous and so fine that
they often defied the most careful observation. The timbre of a voice,
the build of an ankle, the texture of a hand, a movement, a gesture—
since few were as pronounced as Stephen Gordon, unless it were
Wanda, the Polish painter. She, poor soul, never knew how to dress
for the best. If she dressed like a woman she looked like a man, if she
dressed like a man she looked like a woman!

And their love affairs, how strange, how bewildering—how difficult to


classify degrees of attraction. For not always would they attract their
own kind, very often they attracted quite ordinary people. Thus Pat’s
Arabella had suddenly married, having wearied of Grigg as of her
predecessor. Rumour had it that she was now blatantly happy at the
prospect of shortly becoming a mother. And then there was Jamie’s
friend Barbara, a wisp of a girl very faithful and loving, but all woman
as far as one could detect, with a woman’s clinging dependence on
Jamie.
These two had been lovers from the days of their childhood, from
the days when away in their Highland village the stronger child had
protected the weaker at school or at play with their boisterous
companions. They had grown up together like two wind-swept saplings
on their bleak Scottish hill-side so starved of sunshine. For warmth
and protection they had leaned to each other, until with the spring, at
the time of mating, their branches had quietly intertwined. That was
how it had been, the entwining of saplings, very simple, and to them
very dear, having nothing mysterious or strange about it except
inasmuch as all love is mysterious.
To themselves they had seemed like the other lovers for whom
dawns were brighter and twilights more tender. Hand in hand they had
strolled down the village street, pausing to listen to the piper at
evening. And something in that sorrowful, outlandish music would
arouse the musical soul in Jamie, so that great chords would surge up
through her brain, very different indeed from the wails of the piper, yet
born of the same mystic Highland nature.
Happy days; happy evenings when the glow of the summer
lingered for hours above the grim hills, lingered on long after the
flickering lamps had been lit in the cottage windows of Beedles. The
piper would at last decide to go home, but they two would wander
away to the moorland, there to lie down for a space side by side
among the short, springy turf and the heather.
Children they had been, having small skill in words, or in life, or in
love itself for that matter. Barbara, fragile and barely nineteen; the
angular Jamie not yet quite twenty. They had talked because words
will ease the full spirit; talked in abrupt, rather shy broken phrases.
They had loved because love had come naturally to them up there on
the soft, springy turf and the heather. But after a while their dreams
had been shattered, for such dreams as theirs had seemed strange to
the village. Daft, the folk had thought them, mouching round by
themselves for hours, like a couple of lovers.
Barbara’s grand-dame, an austere old woman with whom she had
lived since her earliest childhood—Barbara’s grand-dame had
mistrusted this friendship. ‘I dinna richtly unnerstan’ it,’ she had
frowned; ‘her and that Jamie’s unco throng. It’s no richt for lass-bairns,
an’ it’s no proaper!’
And since she spoke with authority, having for years been the
village post-mistress, her neighbours had wagged their heads and
agreed. ‘It’s no richt; ye hae said it, Mrs. MacDonald!’
The gossip had reached the minister, Jamie’s white-haired and
gentle old father. He had looked at the girl with bewildered eyes—he
had always been bewildered by his daughter. A poor housewife she
was, and very untidy; if she cooked she mucked up the pots and the
kitchen, and her hands were strangely unskilled with the needle; this
he knew, since his heels suffered much from her darning.
Remembering her mother he had shaken his head and sighed many
times as he looked at Jamie. For her mother had been a soft, timorous
woman, and he himself was very retiring, but their Jamie loved striding
over the hills in the teeth of a gale, an uncouth, boyish creature. As a
child she had gone rabbit stalking with ferrets; had ridden a
neighbour’s farmhorse astride on a sack, without stirrup, saddle or
bridle; had done all manner of outlandish things. And he, poor lonely,
bewildered man, still mourning his wife, had been no match for her.
Yet even as a child she had sat at the piano and picked out little
tunes of her own inventing. He had done his best; she had been
taught to play by Miss Morrison of the next-door village, since music
alone seemed able to tame her. And as Jamie had grown so her tunes
had grown with her, gathering purpose and strength with her body. She
would improvise for hours on the winter evenings, if Barbara would sit
in their parlour and listen. He had always made Barbara welcome at
the manse; they had been so inseparable, those two, since childhood
—and now? He had frowned, remembering the gossip.
Rather timidly he had spoken to Jamie. ‘Listen, my dear, when
you’re always together, the lads don’t get a chance to come courting,
and Barbara’s grandmother wants the lass married. Let her walk with a
lad on Sabbath afternoons—there’s that young MacGregor, he’s a fine,
steady fellow, and they say he’s in love with the little lass. . . .’
Jamie had stared at him, scowling darkly. ‘She doesn’t want to walk
out with MacGregor!’
The minister had shaken his head yet again. In the hands of his
child he was utterly helpless.
Then Jamie had gone to Inverness in order the better to study
music, but every week-end she had spent at the manse, there had
been no real break in her friendship with Barbara; indeed they had
seemed more devoted than ever, no doubt because of these forced
separations. Two years later the minister had suddenly died, leaving
his little all to Jamie. She had had to turn out of the old, grey manse,
and had taken a room in the village near Barbara. But antagonism, no
longer restrained through respect for the gentle and child-like pastor,
had made itself very acutely felt—hostile they had been, those good
people, to Jamie.
Barbara had wept. ‘Jamie, let’s go away . . . they hate us. Let’s go
where nobody knows us. I’m twenty-one now, I can go where I like,
they can’t stop me. Take me away from them, Jamie!’
Miserable, angry, and sorely bewildered, Jamie had put her arm
round the girl. ‘Where can I take you, you poor little creature? You’re
not strong, and I’m terribly poor, remember.’
But Barbara had continued to plead. ‘I’ll work, I’ll scrub floors, I’ll do
anything, Jamie, only let’s get away where nobody knows us!’
So Jamie had turned to her music master in Inverness, and had
begged him to help her. What could she do to earn her living? And
because this man believed in her talent, he had helped her with advice
and a small loan of money, urging her to go to Paris and study to
complete her training in composition.
‘You’re really too good for me,’ he had told her; ‘and out there you
could live considerably cheaper. For one thing the exchange would be
in your favour. I’ll write to the head of the Conservatoire this evening.’
That had been shortly after the Armistice, and now here they were
together in Paris.
As for Pat, she collected her moths and her beetles, and when fate
was propitious an occasional woman. But fate was so seldom
propitious to Pat—Arabella had put this down to the beetles. Poor Pat,
having recently grown rather gloomy, had taken to quoting American
history, speaking darkly of blood-tracks left on the snow by what she
had christened: ‘The miserable army.’ Then too she seemed haunted
by General Custer, that gallant and very unfortunate hero. ‘It’s Custer’s
last ride, all the time,’ she would say. ‘No good talking, the whole
darned world’s out to scalp us!’
As for Margaret Roland, she was never attracted to anyone young
and whole-hearted and free—she was, in fact, a congenital poacher.
While as for Wanda, her loves were so varied that no rule could be
discovered by which to judge them. She loved wildly, without either
chart or compass. A rudderless bark it was, Wanda’s emotion, beaten
now this way now that by the gale, veering first to the normal, then to
the abnormal; a thing of torn sails and stricken masts, that never came
within sight of a harbour.

These, then, were the people to whom Stephen turned at last in her
fear of isolation for Mary; to her own kind she turned and was made
very welcome, for no bond is more binding than that of affliction. But
her vision stretched beyond to the day when happier folk would also
accept her, and through her this girl for whose happiness she and she
alone would have to answer; to the day when through sheer force of
tireless endeavour she would have built that harbour of refuge for
Mary.
So now they were launched upon the stream that flows silent and
deep through all great cities, gliding on between precipitous borders,
away and away into no-man’s-land—the most desolate country in all
creation. Yet when they got home they felt no misgivings, even
Stephen’s doubts had been drugged for the moment, since just at first
this curious stream will possess the balm of the waters of Lethe.
She said to Mary: ‘It was quite a good party; don’t you think so?’
And Mary answered naïvely: ‘I loved it because they were so nice
to you. Brockett told me they think you’re the coming writer. He said
you were Valérie Seymour’s lion; I was bursting with pride—it made
me so happy!’
For answer, Stephen stooped down and kissed her.

CHAPTER 45

B y February Stephen’s book was rewritten and in the hands of her


publisher in England. This gave her the peaceful, yet exhilarated
feeling that comes when a writer has given of his best and knows that
that best is not unworthy. With a sigh of relief she metaphorically
stretched, rubbed her eyes and started to look about her. She was in
the mood that comes as a reaction from strain, and was glad enough
of amusement; moreover the spring was again in the air, the year had
turned, there were sudden bright days when the sun brought a few
hours of warmth to Paris.
They were now no longer devoid of friends, no longer solely
dependent upon Brockett on the one hand, and Mademoiselle Duphot
on the other; Stephen’s telephone would ring pretty often. There was
now always somewhere for Mary to go; always people who were
anxious to see her and Stephen, people with whom one got intimate
quickly and was thus saved a lot of unnecessary trouble. Of them all,
however, it was Barbara and Jamie for whom Mary developed a real
affection; she and Barbara had formed a harmless alliance which at
times was even a little pathetic. The one talking of Jamie, the other of
Stephen, they would put their young heads together very gravely. ‘Do
you find Jamie goes off her food when she’s working?’ ‘Do you find
that Stephen sleeps badly? Is she careless of her health? Jamie’s
awfully worrying sometimes.’
Or perhaps they would be in a more flippant mood and would sit
and whisper together, laughing; making tender fun of the creatures
they loved, as women have been much inclined to do ever since that
rib was demanded of Adam. Then Jamie and Stephen would pretend
to feel aggrieved, would pretend that they also must hang together,
must be on their guard against feminine intrigues. Oh, yes, the whole
business was rather pathetic.
Jamie and her Barbara were starvation-poor, so poor that a square
meal came as a godsend. Stephen would feel ashamed to be rich,
and, like Mary, was always anxious to feed them. Being idle at the
moment, Stephen would insist upon frequently taking them out to
dinner, and then she would order expensive viands—copper-green
oysters straight from the Marennes, caviare and other such costly
things, to be followed by even more sumptuous dishes—and since
they went short on most days in the week, these stomachic debauches
would frequently upset them. Two glasses of wine would cause Jamie
to flush, for her head had never been of the strongest, nor was it
accustomed to such golden nectar. Her principal beverage was crème-
de-menthe because it kept out the cold in the winter, and because,
being pepperminty and sweet, it reminded her of the bull’s-eyes at
Beedles.
They were not very easy to help, these two, for Jamie, pride-galled,
was exceedingly touchy. She would never accept gifts of money or
clothes, and was struggling to pay off the debt to her master. Even
food gave offence unless it was shared by the donors, which though
very praiseworthy was foolish. However, there it was, one just had to
take her or leave her, there was no compromising with Jamie.
After dinner they would drift back to Jamie’s abode, a studio in the
old Rue Visconti. They would climb innumerable dirty stone stairs to
the top of what had once been a fine house but was now let off to such
poor rats as Jamie. The concierge, an unsympathetic woman, long
soured by the empty pockets of students, would peer out at them from
her dark ground floor kennel, with sceptical eyes.
‘Bon soir, Madame Lambert.’
‘Bon soir, mesdames,’ she would growl impolitely.
Jamie’s studio was large, bare, and swept by draughts. The stove
was too small and at times it smelt vilely. The distempered grey walls
were a mass of stains, for whenever it hailed or rained or snowed the
windows and skylight would always start dripping. The furniture
consisted of a few shaky chairs, a table, a divan and a hired grand
piano. Nearly every one seated themselves on the floor, robbing the
divan of its moth-eaten cushions. From the studio there led off a tiny
room with an eye-shaped window that would not open. In this room
had been placed a narrow camp-bed to which Jamie retired when she
felt extra sleepless. For the rest, there was a sink with a leaky tap; a
cupboard in which they kept crème-de-menthe, what remnants of food
they possessed at the moment, Jamie’s carpet slippers and blue jean
jacket—minus which she could never compose a note—and the pail,
cloths and brushes with which Barbara endeavoured to keep down the
accumulating dirt and confusion. For Jamie with her tow-coloured
head in the clouds, was not only short-sighted but intensely untidy.
Dust meant little to her since she seldom saw it, while neatness was
completely left out of her make-up; considering how limited were her
possessions, the chaos they produced was truly amazing. Barbara
would sigh and would quite often scold—when she scolded she
reminded one of a wren who was struggling to discipline a large
cuckoo.
‘Jamie, your dirty shirt, give it to me—leaving it there on the piano,
whatever!’ Or, ‘Jamie, come here and look at your hair-brush; if you
haven’t gone and put it next-door to the butter!’
Then Jamie would peer with her strained, red-rimmed eyes and
would grumble: ‘Oh, leave me in peace, do, lassie!’
But when Barbara laughed, as she must do quite often at the
outrageous habits of the great loose-limbed creature, why then these
days she would usually cough, and when Barbara started to cough
she coughed badly. They had seen a doctor who had spoken about
lungs and had shaken his head; not strong, he had told them. But
neither of them had quite understood, for their French had remained
very embryonic, and they could not afford the smart English doctor. All
the same when Barbara coughed Jamie sweated, and her fear would
produce an acute irritation.
‘Here, drink this water! Don’t sit there doing nothing but rack
yourself to bits, it gets on my nerves. Go and order another bottle of
that mixture. God, how can I work if you will go on coughing!’ She
would slouch to the piano and play mighty chords, pressing down the
loud pedal to drown that coughing. But when it had subsided she
would feel deep remorse. ‘Oh, Barbara, you’re so little—forgive me. It’s
all my fault for bringing you out here, you’re not strong enough for this
damnable life, you don’t get the right food, or anything proper.’
In the end it would be Barbara who must console. ‘We’ll be rich
some day when you’ve finished your opera—anyhow my cough isn’t
dangerous, Jamie.’
Sometimes Jamie’s music would go all wrong, the opera would
blankly refuse to get written. At the Conservatoire she would be very
stupid, and when she got home she would be very silent, pushing her
supper away with a frown, because coming upstairs she had heard
that cough. Then Barbara would feel even more tired and weak than
before, but would hide her weakness from Jamie. After supper they
would undress in front of the stove if the weather was cold, would
undress without speaking. Barbara could get out of her clothes quite
neatly in no time, but Jamie must always dawdle, dropping first this
and then that on the floor, or pausing to fill her little black pipe and to
light it before putting on her pyjamas.
Barbara would fall on her knees by the divan and would start to say
prayers like a child, very simply. ‘Our Father,’ she would say, and other
prayers too, which always ended in: ‘Please God, bless Jamie.’ For
believing in Jamie she must needs believe in God, and because she
loved Jamie she must love God also—it had long been like this, ever
since they were children. But sometimes she would shiver in her prim
cotton nightgown, so that Jamie, grown anxious, would speak to her
sharply:
‘Oh, stop praying, do. You and all your prayers! Are you daft to
kneel there when the room’s fairly freezing? That’s how you catch
cold; now to-night you’ll cough!’
But Barbara would not so much as turn round; she would calmly
and earnestly go on with her praying. Her neck would look thin against
the thick plait which hung neatly down between her bent shoulders;
and the hands that covered her face would look thin—thin and
transparent like the hands of a consumptive. Fuming inwardly, Jamie
would stump off to bed in the tiny room with its eye-shaped window,
and there she herself must mutter a prayer, especially if she heard
Barbara coughing.
At times Jamie gave way to deep depression, hating the beautiful
city of her exile. Homesick unto death she would suddenly feel for the
dour little Highland village of Beedles. More even than for its dull
bricks and mortar would she long for its dull and respectable spirit, for
the sense of security common to Sabbaths, for the kirk with its dull and
respectable people. She would think with a tenderness bred by forced
absence of the greengrocer’s shop that stood on the corner, where
they sold, side by side with the cabbages and onions, little neatly tied
bunches of Scottish heather, little earthenware jars of opaque heather
honey. She would think of the vast, stretching, windy moorlands; of the
smell of the soil after rain in summer; of the piper with his weather-
stained, agile fingers, of the wail of his sorrowful, outlandish music; of
Barbara as she had been in the days when they strolled side by side
down the narrow high street. And then she would sit with her head in
her hands, hating the sound and the smell of Paris, hating the
sceptical eyes of the concierge, hating the bare and unhomely studio.
Tears would well up from heaven alone knew what abyss of half-
understood desolation, and would go splashing down upon her tweed
skirt, or trickling back along her red wrists until they had wetted her
frayed flannel wristbands. Coming home with their evening meal in a
bag, this was how Barbara must sometimes find her.

Jamie was not always so full of desolation; there were days when she
seemed to be in excellent spirits, and on one such occasion she rang
Stephen up, asking her to bring Mary round after dinner. Every one
was coming, Wanda and Pat, Brockett, and even Valérie Seymour; for
she, Jamie, had persuaded a couple of negroes who were studying at
the Conservatoire to come in and sing for them that evening—they
had promised to sing Negro Spirituals, old slavery songs of the
Southern plantations. They were very nice negroes, their name was
Jones—Lincoln and Henry Jones, they were brothers. Lincoln and
Jamie had become great friends; he was very interested in her opera.
And Wanda would bring her mandolin—but the evening would be
spoilt without Mary and Stephen.
Mary promptly put on her hat; she must go and order them in some
supper. As she and Stephen would be there to share it, Jamie’s
sensitive pride would be appeased. She would send them a very great
deal of food so that they could go on eating and eating.
Stephen nodded: ‘Yes, send them in tons of supper!’

At ten o’clock they arrived at the studio; at ten thirty Wanda came in
with Brockett, then Blanc together with Valérie Seymour, then Pat
wearing serviceable goloshes over her house shoes because it was
raining, then three or four fellow students of Jamie’s, and finally the
two negro brothers.
They were very unlike each other, these negroes; Lincoln, the
elder, was paler in colour. He was short and inclined to be rather thick-
set with a heavy but intellectual face—a strong face, much lined for a
man of thirty. His eyes had the patient, questioning expression
common to the eyes of most animals and to those of all slowly
evolving races. He shook hands very quietly with Stephen and Mary.
Henry was tall and as black as a coal; a fine, upstanding, but coarse-
lipped young negro, with a roving glance and a self-assured manner.
He remarked: ‘Glad to meet you, Miss Gordon—Miss Llewellyn,’
and plumped himself down at Mary’s side, where he started to make
conversation, too glibly.
Valérie Seymour was soon talking to Lincoln with a friendliness that
put him at his ease—just at first he had seemed a little self-conscious.
But Pat was much more reserved in her manner, having hailed from
abolitionist Boston.
Wanda said abruptly: ‘Can I have a drink, Jamie?’ Brockett poured
her out a stiff brandy and soda.
Adolphe Blanc sat on the floor hugging his knees; and presently
Dupont the sculptor strolled in—being minus his mistress he migrated
to Stephen.
Then Lincoln seated himself at the piano, touching the keys with
firm, expert fingers, while Henry stood beside him very straight and
long and lifted up his voice which was velvet smooth, yet as clear and
insistent as the call of a clarion:

‘Deep, river, my home is over Jordan.


Deep river—Lord, I want to cross over into camp ground,
Lord, I want to cross over into camp ground,
Lord, I want to cross over into camp ground,
Lord, I want to cross over into camp ground. . . .’

And all the hope of the utterly hopeless of this world, who must live
by their ultimate salvation, all the terrible, aching, homesick hope that
is born of the infinite pain of the spirit, seemed to break from this man
and shake those who listened, so that they sat with bent heads and
clasped hands—they who were also among the hopeless sat with bent
heads and clasped hands as they listened. . . . Even Valérie Seymour
forgot to be pagan.
He was not an exemplary young negro; indeed he could be the
reverse very often. A crude animal Henry could be at times, with a
taste for liquor and a lust for women—just a primitive force rendered
dangerous by drink, rendered offensive by civilization. Yet as he sang
his sins seemed to drop from him, leaving him pure, unashamed,
triumphant. He sang to his God, to the God of his soul, Who would
some day blot out all the sins of the world, and make vast reparation
for every injustice: ‘My home is over Jordan, Lord, I want to cross over
into camp ground.’
Lincoln’s deep bass voice kept up a low sobbing. From time to time
only did he break into words; but as he played on he rocked his body:
‘Lord, I want to cross over into camp ground. Lord, I want to cross over
into camp ground.’
Once started they seemed unable to stop; carried away they were
by their music, drunk with that desperate hope of the hopeless—far
drunker than Henry would get on neat whisky. They went from one
spiritual into another, while their listeners sat motionless, scarcely
breathing. While Jamie’s eyes ached from unshed tears quite as much
as from her unsuitable glasses; while Adolphe Blanc, the gentle, the
learned, grasped his knees and pondered many things deeply; while
Pat remembered her Arabella and found but small consolation in
beetles; while Brockett thought of certain brave deeds that he, even he
had done out in Mespot—deeds that were not recorded in dispatches,
unless in those of the recording angel; while Wanda evolved an
enormous canvas depicting the wrongs of all mankind; while Stephen
suddenly found Mary’s hand and held it in hers with a painful pressure;
while Barbara’s tired and childish brown eyes turned to rest rather
anxiously on her Jamie. Not one of them all but was stirred to the
depths by that queer, half defiant, half supplicating music.
And now there rang out a kind of challenge; imperious, loud,
almost terrifying. They sang it together, those two black brethren, and
their voices suggested a multitude shouting. They seemed to be
shouting a challenge to the world on behalf of themselves and of all
the afflicted:

‘Didn’t my Lord deliver Daniel,


Daniel, Daniel!
Didn’t my Lord deliver Daniel,
Then why not every man?’

The eternal question, as yet unanswered for those who sat there
spellbound and listened. . . . ‘Didn’t my Lord deliver Daniel, then why
not every man?’
Why not? . . . Yes, but how long, O Lord, how long?
Lincoln got up from the piano abruptly, and he made a small bow
which seemed strangely foolish, murmuring some stilted words of
thanks on behalf of himself and his brother Henry: ‘We are greatly
obliged to you for your patience; we trust that we have satisfied you;’
he murmured.
It was over. They were just two men with black skins and foreheads
beaded with perspiration. Henry sidled away to the whisky, while
Lincoln rubbed his pinkish palms on an elegant white silk

You might also like