Full JavaScript Recipes: A Problem-Solution Approach 1st Edition Russ Ferguson PDF All Chapters
Full JavaScript Recipes: A Problem-Solution Approach 1st Edition Russ Ferguson PDF All Chapters
com
https://textbookfull.com/product/javascript-
recipes-a-problem-solution-approach-1st-edition-
russ-ferguson/
https://textbookfull.com/product/android-recipes-a-problem-solution-
approach-dave-smith/
textbookfull.com
https://textbookfull.com/product/raku-recipes-a-problem-solution-
approach-j-j-merelo/
textbookfull.com
https://textbookfull.com/product/c-recipes-a-problem-solution-
approach-1st-edition-shirish-chavan/
textbookfull.com
https://textbookfull.com/product/mortal-republic-how-rome-fell-into-
tyranny-edward-j-watts/
textbookfull.com
https://textbookfull.com/product/introduction-to-industrial-
organizational-psychology-ronald-e-riggio/
textbookfull.com
https://textbookfull.com/product/oxford-handbook-of-public-health-
practice-3rd-edition-charles-guest/
textbookfull.com
Exalted Above the Heavens The Risen and Ascended Christ
New Studies in Biblical Theology 47 Peter Orr
https://textbookfull.com/product/exalted-above-the-heavens-the-risen-
and-ascended-christ-new-studies-in-biblical-theology-47-peter-orr/
textbookfull.com
JavaScript
Recipes
A Problem-Solution Approach
—
Russ Ferguson
Keith Cirkel
JavaScript Recipes
A Problem-Solution Approach
Russ Ferguson
Keith Cirkel
JavaScript Recipes: A Problem-Solution Approach
Russ Ferguson Keith Cirkel
Ocean, New Jersey, USA London, United Kingdom
ISBN-13 (pbk): 978-1-4302-6106-3 ISBN-13 (electronic): 978-1-4302-6107-0
DOI 10.1007/978-1-4302-6107-0
Library of Congress Control Number: 2016960744
Copyright © 2017 by Russ Ferguson and Keith Cirkel
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: Welmoed Spahr
Acquisitions Editor: Louise Corrigan
Technical Reviewer: Luca Mezzalira
Editorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black, Louise Corrigan,
Jonathan Gennick, Todd Green, Robert Hutchinson, Celestin Suresh John, Nikhil Karkal,
James Markham, Susan McDermott, Matthew Moodie, Natalie Pao, Gwenan Spearing
Coordinating Editor: Nancy Chen
Copy Editor: Kezia Endsley
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
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.springer.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 www.apress.com.
Apress and friends of ED books 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 Special
Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text are available to
readers at www.apress.com. For detailed information about how to locate your book’s source code, go to
www.apress.com/source-code/. Readers can also access source code at SpringerLink in the Supplementary
Material section for each chapter.
Printed on acid-free paper
This space is always reserved for my brother Rodd and my Dad.
You guys are severely missed.
—Russ
Contents at a Glance
■
■Chapter 1: Working with JavaScript Datatypes����������������������������������������������������� 1
■
■Chapter 2: Working with Expressions����������������������������������������������������������������� 49
■
■Chapter 3: Working with Strings������������������������������������������������������������������������� 91
■
■Chapter 4: Working with Numbers and Math���������������������������������������������������� 137
■
■Chapter 5: Working with Bitwise Operations Against 32-Bit Integers�������������� 151
■
■Chapter 6: Dates and Times������������������������������������������������������������������������������� 173
■
■Chapter 7: Working with Arrays������������������������������������������������������������������������ 181
■
■Chapter 8: Working with Arrays in Loops���������������������������������������������������������� 195
■
■Chapter 9: Working with Objects����������������������������������������������������������������������� 207
■
■Chapter 10: Working with Sets�������������������������������������������������������������������������� 225
■
■Chapter 11: Working with Maps������������������������������������������������������������������������ 233
■
■Chapter 12: Working with Functions����������������������������������������������������������������� 239
■
■Chapter 13: Working with Generators��������������������������������������������������������������� 255
■
■Chapter 15: Working with Symbols������������������������������������������������������������������� 267
■
■Chapter 16: Working with Proxies��������������������������������������������������������������������� 277
v
■ Contents at a Glance
■
■Chapter 17: Working with Classes�������������������������������������������������������������������� 281
■
■Chapter 18: Working with Events���������������������������������������������������������������������� 289
■
■Chapter 19: Debugging and Handling Exceptions���������������������������������������������� 295
■
■Chapter 20: Working with Regular Expressions������������������������������������������������ 301
■
■Chapter 21: Working with Asynchronous Control Flow and Promises�������������� 309
Index��������������������������������������������������������������������������������������������������������������������� 341
vi
Contents
■
■Chapter 1: Working with JavaScript Datatypes����������������������������������������������������� 1
Assigning Variables with the var Statement��������������������������������������������������������������������� 1
Problem�������������������������������������������������������������������������������������������������������������������������������������������������� 1
Solution�������������������������������������������������������������������������������������������������������������������������������������������������� 1
The Code������������������������������������������������������������������������������������������������������������������������������������������������� 1
How It Works������������������������������������������������������������������������������������������������������������������������������������������� 1
vii
■ Contents
viii
■ Contents
ix
■ Contents
x
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
■ Contents
xi
■ Contents
■
■Chapter 2: Working with Expressions����������������������������������������������������������������� 49
Performing an Addition with the + Operator������������������������������������������������������������������ 49
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 49
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 49
xii
■ Contents
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 49
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 50
Performing a Subtraction with the - Operator���������������������������������������������������������������� 50
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 50
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 50
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 50
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 51
Performing Multiplication with the * Operator��������������������������������������������������������������� 51
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 51
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 51
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 51
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 52
Performing Division with the / Operator������������������������������������������������������������������������� 52
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 52
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 52
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 52
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 52
Getting the Remainder of a Division Operation with the Modulo (%) Operator�������������� 53
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 53
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 53
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 53
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 53
Determining If a Value Is Less Than Another with the < Operator���������������������������������� 54
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 54
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 54
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 54
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 55
Determining If a Value Is Greater than Another with the > Operator������������������������������ 55
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 55
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 55
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 55
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 56
xiii
■ Contents
Determining If a Value Is Less than or Equal to Another with the <= Operator����������� 56
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 56
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 56
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 56
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 57
Determining If a Value Is Greater than or Equal to Another with the >= Operator��������� 57
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 57
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 57
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 58
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 58
Determining If a Value Is Strictly Not Equal to Another Using the !== Operator������������ 66
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 66
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 66
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 67
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 68
xiv
■ Contents
Using the Increment (++) Operator to Increase the Value of a Number Variable����������� 69
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 69
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 69
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 70
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 70
Using the Decrement (--) Operator to Decrease the Value of a Number Variable����������� 70
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 70
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 71
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 71
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 71
Using the Unary Subtraction (-) Operator to Flip the Sign of a Number������������������������� 72
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 72
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 73
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 73
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 73
xv
■ Contents
xvi
■ Contents
■
■Chapter 3: Working with Strings������������������������������������������������������������������������� 91
Understanding Unicode Strings�������������������������������������������������������������������������������������� 91
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 91
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 91
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 91
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 92
xvii
■ Contents
Getting a Single Character’s UTF Code Unit from a String with charCodeAt( )������������� 100
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 100
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 101
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 101
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 101
Getting a Single Character’s UTF Code Point from a string with codePointAt( )����������� 102
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 102
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 102
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 102
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 103
xviii
■ Contents
xix
■ Contents
Finding the Index of the Last Occurrence of a Substring with lastIndexOf( )���������������� 113
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 113
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 113
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 113
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 114
xx
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
■ Contents
xxi
■ Contents
■
■Chapter 4: Working with Numbers and Math���������������������������������������������������� 137
Converting Strings to Numbers������������������������������������������������������������������������������������ 137
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 137
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 137
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 137
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 138
Creating a Number Object�������������������������������������������������������������������������������������������� 138
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 138
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 138
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 138
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 138
xxiii
■ Contents
xxiv
■ Contents
■
■Chapter 5: Working with Bitwise Operations Against 32-Bit Integers�������������� 151
What Are 32-Bit Integers?�������������������������������������������������������������������������������������������� 151
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 151
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 151
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 151
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 151
Multiplying by Powers of 2 with the Left Shift (<<) Operator�������������������������������������� 152
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 152
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 152
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 152
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 152
Dividing by Powers of 2 with the Sign-Propagating Right Shift (>>) Operator������������ 154
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 154
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 154
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 154
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 155
Using the Zero-Fill Right Shift (>>>) Operator to Ensure a Variable
Is a 32-Bit Unsigned Integer����������������������������������������������������������������������������������������� 156
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 156
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 156
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 156
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 157
Using the Bitwise NOT (~) Operator to Swap All Binary Bits in a 32-Bit Integer���������� 158
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 158
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 158
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 158
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 158
xxv
Random documents with unrelated
content Scribd suggests to you:
“Please,” said Desmond.
And whirling through the Solar system, belonging neither to earth
nor heaven, was performed surely the strangest rite ever known from
time immemorial. And it was in this strange place, in this strange
manner that Desmond and Mavis’ son—John Alan—was named.
CHAPTER II
ADRIFT IN THE SOLAR REGIONS
Life in the Argenta became very monotonous. After the first throes
of despair, the glimpse of the glorious expanse of the Heavens served
to cheer the prisoners within the ship. They had no clocks that were
going. During the terror of the first few days time had mattered so
little to them that they had let them run down. They now arranged to
set all the clocks, and judge the time accordingly, and plan out their
days. Rise at eight; lunch at one; tea at four; and dinner at seven and
then to bed. The “night” would pass and they would begin another
“day.”
They reckoned they had sufficient food to last the twelve earth
months, and they could exist in comfort for three hundred and sixty-
five days. And with the minutest care, perhaps even longer. “We can’t
live in space for more than twelve months, surely,” said Mavis, but
Sir John did not answer her. They had consumed perhaps an eighth
of their water supply, and had the supply of concentrated water
essence untouched. Still, they were afraid to waste any for washing
purposes, and considered it a treat to be allowed to dip their fingers
in any fluid that was left over from cooking; even a drop of cold tea
proved a boon to them, and they gratefully damped cloths in it and
wiped their hot and dry faces.
Alan fixed a piece of paper on the wall of the front cabin, and every
night before they retired, he would tick off the number of the day
from the time they had reset their clocks and begin to count again.
Thirty, forty, fifty, so the “days” passed, and little John Alan grew
enormously. The few garments that had been packed in their hurried
flight were now too small for him, and Mavis was forced to use some
of her own dresses, and cut them up for the growing child. He alone
was unconscious of the danger of their peculiar position, and he
crowed and gurgled and bit his toes, in complete babyish happiness
and delight. If anything, Mavis had grown more beautiful after the
arrival of her child. Her eyes glowed with maternal pride, and her
cheeks were flushed with joy as she watched her baby, born into such
a strange life, grow day by day fairer and more loving.
The library aboard, which Sir John had had the foresight to install
in his giant Argenta, proved a godsend to the weary travellers. Every
day they read aloud some old literary favourite, and renewed their
acquaintance with Sam Weller, Pip, the Aged P, and Little Nell;
laughed over the experiences of the “Innocents Abroad” enjoyed
again the story of “Three Men in a Boat.” But even with these
diversions, with chess, dominoes, and draughts; with singing and
playing, they grew tired of their enforced inactivity, and chafed at
their surroundings.
Their air supply was excellent; the mechanism never failed in its
work; certainly the air grew hot and fetid at times but by the aid of
electric fans it was freshened and purified. Every day they looked out
of the little glass window, and drank in the glories of the heavens.
One day, it was the ninety-eighth according to Alan’s chart, Mavis
startled them all by a sudden exclamation.
“What is it, my dear?” asked Sir John, looking up from an
interesting game of chess he was enjoying with Alan.
“Look at Jupiter! Isn’t he large to-night?” said she. “Why,
yesterday he looked like a big star, to-day he is like the moon at
harvest time.”
They all crowded round the little window.
“By Jove, you’re right,” said Alan. “We must be sailing in a direct
line toward him.”
“How plain the clouds are upon him,” said Desmond. “You can see
them plainly right across his face.”
The belts across the face of Jupiter were certainly very plain;
across the surface of the planet they floated pearly white, like masses
of “snow-clouds” as seen in England on a hot summer’s day. From
the equatorial region they merged, both north and south from a
glorious coppery colour, becoming a deep, ruddy purplish tint at the
poles.
“Are they clouds like ours?” asked Mavis wonderingly.
“I don’t think it has ever been proved what they really are,”
answered Alan. “I think the general theory is, that those clouds as
you call them are, in reality, a vapour-laden atmosphere that floats
across the orb.”
“I should love to go there,” said Mavis.
“Well, it looks as though we were making for that part of the
firmament,” said her uncle.
“It certainly does,” she retorted. “But when shall we reach there?”
At that moment Masters and Hector came in, in great excitement.
“The engines are working,” announced Hector enthusiastically.
“What!” from all.
“It’s true. Masters and I were tinkering at them this morning,
when suddenly the little starting cog flew round, there was a roar, a
flash of sparks, and they started properly.”
This was indeed good news, for ever since the end of the world the
airship had been propelled through space by some unknown outside
influence; her engines not only refused to work but her steering
apparatus refused to act.
“I intend navigating straight ahead,” announced Masters. “I’ll have
eight engines going, and then we ought to get up a speed of over four
hundred and fifty miles; that together with the pace we are already
travelling should help us considerably in reaching somewhere, if
there is anywhere for us to get.”
Eagerly they all went into the engine room, and watched first one,
then another of the powerful engines set going. They were however
surprised to find that they felt no difference in their speed; yet the
speedometer registered four hundred and twenty miles, and all eight
engines were working merrily.
They went back to the bows, and watched the universe stretched
out before them. They passed close to a star, whose name they did
not know, and its radiance lit up the little cabin for fourteen days,
that were marked off religiously on Alan’s calendar. Then came
another terrible time, when depression took hold of them all again,
and they would sit, silent, staring into space. Their eyes were dull
and lustreless; their limbs cramped from lack of exercise, and their
brains torpid and sluggish.
Perhaps Alan felt the deprivation of air and exercise most, but he
continued to be the cheeriest of them all.
“Oh, for some green vegetables,” sighed Mavis one day. John Alan
had been particularly restless, and she felt more than usually
miserable.
“And plenty of nice rabbit food,” went on Alan cheerfully. “Crisp,
long lettuces, the rosy radish, juicy tomatoes, and above all the cool,
refreshing slices of the unwholesome cucumber.”
“Oh, Alan, I’m so miserable,” she sobbed. “Will this awful
existence never end? Shall we just die here, and this ship become the
meteoric tomb of seven unfortunates of the world? A tomb always
spinning on, on, through endless space, through endless time, like
some lost soul.”
“Lost world, you mean,” corrected Alan. “You are mixing your
metaphors, and when a lady does that, it’s a sure sign she wants a
cup of tea!”
“I don’t want a cup of tea, Alan. I just want to get a breath of air.
Alan, couldn’t you persuade Masters to open the shutters? Couldn’t
we just go on to the deck for five minutes—only five minutes?” she
pleaded.
“My dear,” said Alan gently. “It’s quite impossible. Now listen
carefully to what I am saying. Long, long ago, we were out of the
atmosphere and the gravitation of our earth. In some way or other,
the tornado that accompanied the end of our world drove us through
space where nothing is! Oh, I know it sounds complicated, dear, but
by all the knowledge of science, as taught by the most advanced
astronomers, long ago we should have been suspended in space,
unable to move or be moved, outside the gravitation of other worlds;
just atoms, motionless, still. That hasn’t happened. We have defied
the great authorities, and are being whirled through the heavens by
some power unheard of by the scientists of the earth. Still, dear, we
do not know whether there is air outside. Should we lift the shutters
that protect us, we might find we were unable to exist.”
“That’s the word,” cried Mavis. “We aren’t living now. We are only
existing. We don’t know from hour to hour what terrible fate may
await us. If by lifting the shutters we kill ourselves, surely that is
better than this lingering death.”
“Mavis, Mavis, don’t.”
“Do you know we have only a month’s supply of food left?”
Alan looked at her in horror. “You don’t mean that, Mavis?” said
he incredulously.
“My dear Alan, you are just like all men. Sufficient for the day!
That’s your motto. You never enquired about the food. Since I took
over the culinary department, none of you have worried a bit, while
day by day I’ve seen our stock of provisions grow less and less. In a
month’s time, Alan, our food will be totally exhausted.”
“What about the condensed foods?”
“Oh we still have some of them—perhaps with extreme care they
would last another four weeks, and then—the end.”
“Why didn’t you tell me before, Mavis?”
“Oh I couldn’t,” hysterically. “You were all so contented. Besides I
didn’t realize the seriousness of it myself until to-day. Our flour is
nearly gone. You yourself said the bread wasn’t as good this morning.
Of course it wasn’t. It was just mixtures of every cereal I could think
of to try and make it last out.”
This news was indeed serious, and Alan walked thoughtfully to his
chart. Yes, he ought to have known. It registered five hundred and
fifty-five days. Over eighteen earth months they had been flying
through the heavens. Their food had lasted magnificently.
“Water?” he queried.
“We finished the tank water long ago. I’m pretty well through with
the cubes.”
“Let me come and see the food supply.”
Carefully he went over every item. Even yet, there seemed to be
enough to feed an army, but he knew how little there was in reality.
“I think if we have one good meal a day, we ought to make it last
longer,” said he. “After all, one good meal is better than three small
ones, and incidentally, we save over the one transaction. We must
sleep longer, that’s all. We will get up at noon, and have a cup of tea
and a biscuit. At four we will have dinner, and if we retire at eight, a
cup of cocoa then should suffice us. The longer we remain in bed the
less food we shall require. Come, let us tell the others.”
Sir John took the news very quietly. Not a muscle of his face
twitched—he might have been receiving a most ordinary
announcement. Masters shrugged his shoulders indifferently, and
Murdoch went on with his work as if he had not heard. Desmond
took the news badly, however. His face grew ashen. “Why should this
have come upon us?” he cried. “We had been through so much.
Happiness came my way at last, and now—” He drew Mavis fiercely
to him. “I won’t lose you. There must be some way out.”
“There is none, my boy,” said Sir John, “so you had better make up
your mind to that at once. Here we are and here we must remain, till
by some merciful intervention, we die, or are given release.”
“Where shall we ever find release?” from Desmond.
“In some new world, perhaps.”
“How big Jupiter is,” said Alan, looking out into the vastness. “He
is certainly a wonderful planet,” said Mavis.
“Is it my fancy or are we slowing down?” asked Sir John.
“I’ve wondered the same thing myself,” said Masters. “For the last
few days I have noticed an appreciable difference in our speed.”
But although the difference was so slight as to be almost
undiscernible, the new topic of conversation gave the prisoners new
life.
The days passed—the quantity of the food they consumed grew
daily less and less, and they were growing weaker and weaker every
day. At length they gave up their cup of tea in the mornings—their
tea had gone. Then they halved their dinner portions making one
day’s share of food last two! But all the same the dreaded day came
only too soon, and five hundred and ninety-five days after Alan had
put up his calendar, they found they had only a few tins of
concentrated food left. They were all hungry. Little John Alan grew
fretful, his mother feverish. There was silence in the little front cabin,
the silence of the grave. The little party were all half asleep, when
suddenly Alan rose. “What’s the matter?” he asked quickly.
“What is it?” asked his uncle.
“Don’t you realize?—we’ve stopped! We’ve stopped!” It was true,
the Argenta was stationary at last! At the same moment Masters
came rushing in.
“We’ve stopped!” he cried. “The engines have refused again to
work.”
They all crowded round the little “lookout,” but could see nothing.
For the first time for nearly two years their vision was limited. Gone
was the brightness of Jupiter, gone the glorious Magellanic Cloud—
gone, too, the many thousand points of light that enriched the
heavens. All about them was a moving vapour. It was unlike clouds,
but surged and swirled like heavy snow flakes. It was a whitish
vapour that looked like steam—that altered again and took on the
hue of thick yellowish smoke.
“Where are we?” asked Mavis. “Can’t we get out?”
“We’ll see,” said Alan soothingly.
But still Mavis went on pleadingly. “Oh surely our chance has
come at last. If we opened the shutters now, we might get free
altogether.”
The next morning, Murdoch was missing. His bed had not been
slept in. “Where’s Murdoch?” asked Alan of Masters.
“I don’t know. I’ve been expecting him to relieve me in the engine
room every minute. Is he in the kitchen?”
“No. I can’t find him anywhere.”
“Good God! Then I know what he has done,” said Masters
brokenly. “He was very upset over Mrs. Desmond yesterday. She
wanted me to open the shutters. Come.”
At the stern of the ship and on the lower deck was a little trap door
in the metal covering. “He’s gone through there,” said Masters
hoarsely. “He asked me a lot of questions about it last night. I told
him about the mechanism of this trap and he suggested we should go
out on deck, and see if it was possible to breathe out there. I laughed
at him and thought no more about the matter.”
As he was speaking he deftly wound a scarf about his nose and
mouth, and stuffed his ears with cotton wool saturated with oil. He
touched a spring and a sheet of metal unfolded and when it rested at
last in position, it formed a tiny air tight closet outside the trap. “I
shall open the trap as quickly as I can,” said he quickly. “On the other
side the deck is opened up and there is a space left large enough to
test thoroughly the outer air. But by the aid of this “cubby-hole” we
still have our ether protection kept safe all round the ship. Now I am
going out to see if Murdoch is there. If I don’t come back, don’t
search for me. It will be too late.”
“Masters, don’t go!” urged Alan.
“I must go,” grimly, “but I beg of you, if I don’t return in ten
minutes, forget I ever existed.”
Without another word he slipped into the little boxlike chamber,
and the door snapped to after him. They heard the sound of a click,
rushing air, and then, silence.
Five minutes passed—six—seven—eight. Sir John, Desmond and
Mavis had come up in time to hear the trap close, and quickly Alan
explained the position.
“Why did you let him go?” cried Mavis.
“Murdoch went for you, my dear,” he answered sternly. “Masters
went to save him.”
Mavis covered her face with her hands, and the tears trickled down
her face.
“My dear, don’t take it to heart,” went on Alan kindly. “If anything
happens to Murdoch, he will have given his life for his friends.”
Then a muffled cry came from within the little chamber. Quickly
Alan touched the lever, the folds of metal rolled back, and two figures
fell forward on their faces.
“Water,” commanded Alan, and Mavis rushed to get some.
“Have you any brandy left?” asked Sir John.
“A very little.”
“Bring some too,” he cried as Mavis disappeared into the kitchen.
Tenderly they wiped blood and sweat from the faces of the
unconscious men.
Masters opened his eyes. “Out there,” said he hoarsely. “Terrible
smell—sulphuric—can’t breathe properly—whirling clouds—eyes
smart—don’t go again.”
“He’ll do,” said Sir John. “How’s Murdoch?”
“He’s so terribly cold,” said Mavis.
Alan took his place by the still form. “Brandy,” said he. He looked
at the man on the floor. Thick veins like whipcords stood out upon
his forehead. Blood trickled from his nose, his ears, his mouth. His
lips were swollen, and were blue in colour and cracked.
“He’s gone,” said Alan.
“Dead?” cried Mavis in horror.
“Quite dead.” Gently they carried the dead man, who had risked
his life for his friends, to his little sleeping cabin. Tenderly they laid
him on his bed, covered up his face, and closed the door softly
behind them. Then they went back to Mavis who was watching over
Masters.
“How is he?” asked Desmond.
“Better, I think. He asked for water. I think he is sleeping now.”
Alan bent over their old and valued friend. The look of pallor had
vanished, the veins subsided, he was breathing naturally.
“Poor Murdoch,” sobbed Mavis. “I feel it was my fault. I was
always worrying you to open the shutters and let us go outside.”
“Don’t worry, little one,” said Sir John. “He died like an English
gentleman.”
“Oh how terrible everything is,” she sobbed hysterically. “There
seems no end to our torment. Oh this horrible place, this horrible
ship of doom!”
CHAPTER III
THE VISION OF A NEW WORLD
Perfect silence, perfect stillness, and the clouds whirled round and
round outside.
In vain they tried to move the ship. The engines worked smoothly,
and with perfect rhythm, but were powerless to propel the Argenta.
The death of Murdoch had a terribly depressing effect on every one
—they all missed his kindly brusqueness, his forethought and stolid
help.
When Masters was sufficiently recovered he told his story. “I got
through the ether all right,” said he. “I was through in a second and
was standing on the exposed deck at the mercy of the elements. The
cold was intense—I’ve never before experienced anything like it. In
those few seconds it just cut through me. I could hardly see—my eyes
filled with water, and smarted terribly as the gaseous vapour touched
them. I lowered my handkerchief for the tiniest fragment of a second,
and drew a very slight breath. The effect was terrible. My lungs felt as
if they would burst—my mouth felt as if it had been seared with hot
irons—my senses reeled; I felt as if I should fall. Then I became
conscious of Murdoch lying huddled at my feet. I pulled him into the
cabin after me, and well,—you know the rest. Poor Murdoch—I was
too late.”
The excitement following the loss of Murdoch and Masters’
adventure after him, had made the hungry prisoners forget the
emptiness of their larder. They all sat down to a hearty meal, and it
was only at the end they realized it meant their being on still shorter
rations in the future. And only too soon the larders were indeed
empty! Mavis grew too weak to move, and lay helpless on her bed,
her baby at her breast. Masters was the last to give in, and as he
walked unsteadily to his cabin, he had visions of Sir John on one
chair and Alan on another, each vainly trying to whisper words of
comfort to the other.
Still the ship remained motionless—the stillness was of the grave.
Suddenly a whitish beam of light shot out through the clouds, and
Alan saw a new moon rising. And as he watched he saw another skim
the heavens, and another, and yet another. He looked at them in
perplexity—four pink tipped crescents in the sky!
“Four Moons! God!” he cried. “The four satellites of Jupiter! Or
should there be eight? Four—eight—eight—four.” His brain muddled.
Four Moons visible at once! Jupiter! He was witnessing the rise of
four of the planet’s moons! He was watching them through the misty
clouds—then came a blessed sense of oblivion, and he too, lost
consciousness. When he awoke again, it was with a feeling that the
Argenta was again moving through space—moving slowly, but with a
speed that was gradually quickening. He staggered to his feet, and
bent over his uncle. Sir John was still breathing, but there was a
curious greyness in his face, and Alan moistened his lips with a drop
of brandy. The old man moved, and opened his eyes. “Drink a little,”
said Alan kindly. “It will do you good.”
Sir. John managed to swallow a little of the burning fluid, and
sighing naturally, closed his eyes in sleep. With difficulty, Alan
managed to reach Desmond’s room, for he was very weak. He found
Mavis lying on her bed, hardly breathing: the babe lay in her arms
sleeping peacefully. She had given the very essence of her strength to
her child, and he had scarcely suffered at all.
Desmond was breathing heavily, jerkily, the breath came like sobs
from between his clenched teeth. Alan forced some of the brandy
between his lips and said huskily, “Dez, old boy: don’t leave me, old
chap; we’ve been through some tight corners, don’t give up yet.”
Desmond struggled to a sitting position. “Good old Lanny,” he
muttered.
“I must see Masters,” said Alan. “Keep up, if you can, till I return.”
Alan reeled from side to side in his weakness as he struggled on to
Masters’ cabin. It was empty! He was almost too weak to think or act
coherently.
“Masters,” he moaned. “Where are you?” Slowly he made his way
back to the little room in the bows, and as he neared it, a brilliant
beam of light shot across his path. The unexpectedness of it threw
him off his balance, and he would have fallen, had not Masters
rushed forward and put his arm about him.
The light was strong. So strong that they could feet the heat of its
rays through the little glass window.
“What is it?” he asked.
Masters could hardly speak. His lips were swollen and blackened,
and his tongue parched. “Help,” said he thickly. “That light is like a
magnet—it is drawing us somewhere. It’s sent out by human agency I
am sure. See how it flutters and fades, only to come bright again.”
They watched the ray—it was focussed directly on the bows, and it
seemed to be drawing them closer and closer to some harbour of
refuge. Still they were going through the encircling clouds, which had
suddenly turned to a most beautiful roseate hue. Then without any
warning they emerged and found they were gazing on the most
wonderful scene they had ever beheld.
It was more wonderful than their thoughts could have expressed.
Imagine hovering over the most wondrous piece of natural scenery—
double—treble its beauty, and even then you could have no idea of
the grandeur, the poetry of the picture they gazed upon.
They were, perhaps, three thousand feet up. Mountains rose all
round with rocky crevasses, and wonderful waterfalls dashing down
their sides. Foaming waters trickled and bubbled and laughed by the
sides of grassy paths. An inland lake glowed in the glory of the
sunshine. Trees of all kinds nestled in the valleys and climbed the
hillsides.
A sea—a glorious azure sea—with dancing waves and white flecked
foam rolled merrily in and out on wonderful white sands. There were
rocks and caves, and velvety grass slopes along the sea shore;
babbling brooks merged into the blue, blue waters; tall lilies, virginal
white, mingled with roses, red like wine, and grew in clusters at the
water’s edge. All was nature at her best—unspoiled by man.
Wooded islets were dotted about in still more wonderful bays;
birds white as snow, birds with plumage rainbow-hued floated idly
on the waters, and added to the picturesque beauty. They could see
little buildings nestling among the trees here and there, buildings
that, like the châlets of Switzerland, only added to the beauty of the
scene.
The airship had stopped suddenly, and they were unable to move
her, and still they hovered over the wonderful land. Sea—sky—both
of a most glorious blue; the verdure of this new land was green—“The
same as our world,” murmured Alan.
“But with what a difference,” whispered Sir John.
“I never knew what the sea was until now,” said Alan. “I never
realized what ‘colour’ was—what blue or green meant, until I looked
down yonder.”
New life was born in the three men. “I’ll call Desmond,” said Alan.
Mavis was lying as he had left her—white, inert, silent. “Leave her,”
he told his cousin. “She will be quite safe; but we’ve news at last—we
are in sight of land.”
When he reached the bows again, he saw they had dropped a few
hundred feet, and were now well below the summit of the mountains.
Below them, in a fertile valley, they saw what they thought were six
giant birds running along a field. They rose, soared straight up, and
flew directly toward the Argenta. They were like swans with
outstretched wings, and necks like swans; but never had they seen
birds of such a monstrous size.
“They are as big as a small plane,” said Sir John wonderingly.
“By Jove, I believe that’s what they are,” said Alan.
As the “birds” drew nearer, they could see that the body was in
reality the car of the plane. Soon six were circling round the Argenta,
and the prisoners within could see figures standing in the cars of the
strange looking aeroplanes.
The Argenta gave a jolt, and quivered from stem to stern, and they
felt themselves sinking. The newcomers had thrown out some kind of
grappling rope and were pulling them to earth. They were nearer to
this wonderful country. Already they could see the brilliant flowers—
trees laden with wonderful fruit and bright plumaged birds fluttering
about without any sign of fear.
“Release the shutters,” said Alan hoarsely.
“No,” said Sir John with decision. “Remember we have on board a
defenceless woman and her child. We don’t yet know if we are in the
hands of friends or enemies. I’ll get my revolver. Dez, my boy, I’ll
give it to you. Stay in your cabin and be prepared. You understand?”
“Shoot—her?” asked Desmond hoarsely.
Sir John bowed his head. “Surely you would rather do it than me?”
“Yes—but—”
“There is no ‘but,’ my boy. Rather death than horrors unnameable.
Stay in the cabin with your wife and child. If I think we are in good
hands I will call you. Otherwise, I will give our whistle—the one we
used when you were boys—the three sharp calls, and a long minor
note,” and he illustrated it softly. “If you hear that,—don’t hesitate,
my boy.” They gripped hands, and Desmond, dazed, speechless,
walked unsteadily out of the room, and they heard the click of his
cabin door as it closed behind him.
Slowly, but surely the Argenta was being dragged down to the field
below. At last they touched solid ground—there was a scrunch and a
grating—they were on some earth at last.
“Alan,” said Sir John grimly. “I have two other revolvers on board.
Masters, if the worst comes to the worst, and I give the warning
whistle for Mr. Desmond, go in to him. If he does not turn the
weapon on himself do it for him—and keep a spare bullet for
yourself.”
“I understand, sir.”
The six white “birds” had also reached land, and from out of the
bodies they saw strange figures appear. The figures were like
themselves—yet how different! The men approaching were perhaps
under average height, but they were beautifully moulded, muscular
with a symmetry of form that was glorious to behold.
All but one wore white—a garment that reached to their feet, and
which resembled in shape a Roman toga. This white garment was
embroidered with richly coloured silks at the neck, wrists and hem.
On their heads, they wore fillets of gold. The leader was garbed in a
garment of the same shape, but of a glorious blue bound with gold,
and his fillet was studded with gems that shone and flashed in the
sunlight. All walked up to the Argenta and smiled through the little
window at the occupants. Then the leader opened his hands—held
them up empty, and with a charming smile, bowed low before them.
Then he seemed to issue a command, and all the others, there were
altogether perhaps thirty of them, followed his example, and bowed
before them.
“They look friendly,” said Sir John. “Masters, let the shutters be
raised—then stand near Mr. Desmond’s cabin. If I shout—‘view
halloo!’ bid him to come out on to the upper deck, but—”
“But if I hear the whistle, sir, I shall know what to do.”
“Keep your revolver hidden, Alan,” said Sir John, and they made
their way to the upper deck.
They waited in silence for the ether to be pumped back into its
cylinders, and for the shutters to lift. Gradually light came creeping
in through chinks here and there—higher and higher was lifted the
moving metal, until at last the two men drank in fresh air and bathed
in glorious sunshine once again. They found they could scarcely
move along the deck—in fact it was with the greatest difficulty they
could keep their balance. They felt horribly material and gross.
“What is it?” whispered Alan.
“The law of gravity, my boy. Wherever we are, I should say it is
about three times the strength of that we were used to when we were
on Terra. I think we have about trebled our weight.”
The strangers had advanced—the leader was smiling graciously.
He gave another command, and his band of followers came to a
sudden halt, and he approached the Argenta—alone. He addressed
them in a language they did not understand.
“I do not understand—” commenced Sir John, but before he could
say any more the stranger spoke—haltingly it is true, and as if unused
to it, but he spoke in English.
“Where are we?” cried Sir John in amazement.
“You are on, what I think you would call—Jupiter.”
“Jupiter?”
“Yes. And may I welcome you strangers to our land of plenty. I
know not who you are or whence you come—but you are welcome—
very welcome. But you look tired—”
“You are not enemies, then?” cried Sir John.
“Enemies?” repeated the Jovian. “I understand not the word.”
“You are friends?”
“Friends of course—we are all friends. Can you find a more
beautiful word than friendship?”
“Thank God! Thank God!” cried Sir John, and with a wild “View
Halloo” issuing from his lips, he fell senseless to the ground.
CHAPTER IV
JUPITER AND THE JOVIANS
They walked down a lovely avenue to the outer gates. It was grass-
covered, soft and velvety and cool. Birds with the gayest plumage
hopped among the branches of the trees, and came fearlessly up to
the strangers. One bird, perhaps as big as an English bullfinch, of
many colours and with a fan-shaped tail, perched on Mavis’
shoulder, and chirped prettily to her.
“How wonderful!” said she.
“Did not your, birds do that?” asked Waz-Y-Kjesta.
“No, they were too nervous.”
“Nervous?”
“Yes—frightened—terrified,” she explained.
“I understand the meaning of the word you utter,” said he, “but
you will not find the sensation of fear known on Keemar. We live in
harmony with our birds, our animals, and even our fish. They are all
our friends.”
At the end of the avenue they found themselves on a broad road.
Hills rose up at the side, steeply in some places, while in others the
rise was more gradual, leaving moorland and valley in view. Houses
were built at intervals along the roads, all of wonderful, coloured
marbles, but they were all surrounded by beautiful grounds, and
added to the scene.
“Oh,” said Mavis suddenly. “There’s a shop.”
Waz-Y-Kjesta looked puzzled, and followed her gaze. “Oh yes, you
mean our Omdurlis. How else should we get food to eat and clothes
to wear?”
“How then do you manage about your coinage? Do you have
money?” asked Alan curiously.
“I know not the word.”
“How do you buy things—what do you give in exchange?”
“Oh, we have laika—royla, suka and minta,” said he; and he drew
from his purse that hung satchel-wise across his shoulders, some
coins. The first was square, as large as a five shilling piece, and green
in colour.
“This will purchase the most,” he said. “Five roylas make a laika.”
The royla was exactly the same, but no bigger than a florin. “Then
there are ten sukas to a laika, and twenty mintas.” The last two coins
were of a bronze hue and as big as a shilling and a sixpence.
“I expect those five coins are equal to a fiver, a sovereign, a two
shilling piece and a sixpence,” said Mavis thoughtfully.
“How do you get your money?” asked Sir John.
“Oh, from the Rorka,” explained the Waz. “I am a Waz—I receive
one thousand roylas or two hundred laikas a murvin. The Jkak will
get a thousand laikas, while little Morkaba, who is born of the
workers, gets but ten and her food.”
“I suppose the shopkeepers make a lot of money,” said Desmond.
“Oh no. All members of the Omdurlis get one hundred laikas. All
that they make above that they are bound to send to the Rorka. He
places all the surplus in the general fund which is held in reserve for
all Keemarnians. As each male Keemarnian reaches the age when he
has seen the Kymo rise three thousand and thirty times, he journeys
to Hoormoori, makes his bow to the Rorka, and receives from him
his manhood. According to the station in life in which he has been
born, and from which he has sprung, so he learns to take his part in
life.”
“It is a wonderful system in theory,” said Sir John. “But how does
it work in practice?”
“It is our custom,” was all the reply the Waz made.
“But don’t you sometimes find you get dissentient spirits? Don’t
they rebel against this formality? Don’t they want to make more
money than is allowed by custom? Don’t you sometimes have trouble
from these spirits?”
Waz-Y-Kjesta smiled. “In our books of science we have read that in
other places than ours—there were troubles like those you name.