100% found this document useful (4 votes)
63 views

Full JavaScript Recipes: A Problem-Solution Approach 1st Edition Russ Ferguson PDF All Chapters

Approach

Uploaded by

niotishedden
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
63 views

Full JavaScript Recipes: A Problem-Solution Approach 1st Edition Russ Ferguson PDF All Chapters

Approach

Uploaded by

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

Download the full version of the textbook now at textbookfull.

com

JavaScript Recipes: A Problem-Solution


Approach 1st Edition Russ Ferguson

https://textbookfull.com/product/javascript-
recipes-a-problem-solution-approach-1st-edition-
russ-ferguson/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Android Recipes A Problem-Solution Approach Dave Smith

https://textbookfull.com/product/android-recipes-a-problem-solution-
approach-dave-smith/

textbookfull.com

Raku Recipes: A Problem-Solution Approach J.J. Merelo

https://textbookfull.com/product/raku-recipes-a-problem-solution-
approach-j-j-merelo/

textbookfull.com

C Recipes - A Problem-Solution Approach 1st Edition


Shirish Chavan

https://textbookfull.com/product/c-recipes-a-problem-solution-
approach-1st-edition-shirish-chavan/

textbookfull.com

Numerical Simulation and Experimental Investigation of the


Fracture Behaviour of an Electron Beam Welded Steel Joint
1st Edition Haoyun Tu (Auth.)
https://textbookfull.com/product/numerical-simulation-and-
experimental-investigation-of-the-fracture-behaviour-of-an-electron-
beam-welded-steel-joint-1st-edition-haoyun-tu-auth/
textbookfull.com
ENVIRONMENT ECOLOGY AND EXERGY ENHANCED APPROACHES TO
ENVIRONMENTAL AND ECOLOGICAL MANAGEMENT 1st Edition Marc
A. Rosen
https://textbookfull.com/product/environment-ecology-and-exergy-
enhanced-approaches-to-environmental-and-ecological-management-1st-
edition-marc-a-rosen/
textbookfull.com

Mortal Republic How Rome Fell Into Tyranny Edward J. Watts

https://textbookfull.com/product/mortal-republic-how-rome-fell-into-
tyranny-edward-j-watts/

textbookfull.com

Programming with MicroPython embedded programming with


Microcontrollers and Python First Edition Nicholas H.
Tollervey
https://textbookfull.com/product/programming-with-micropython-
embedded-programming-with-microcontrollers-and-python-first-edition-
nicholas-h-tollervey/
textbookfull.com

Introduction to Industrial Organizational Psychology


Ronald E. Riggio

https://textbookfull.com/product/introduction-to-industrial-
organizational-psychology-ronald-e-riggio/

textbookfull.com

Oxford handbook of public health practice 3rd Edition


Charles Guest

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

About the Authors���������������������������������������������������������������������������������������������������� lv


Acknowledgments������������������������������������������������������������������������������������������������� lvii
Introduction������������������������������������������������������������������������������������������������������������ lix


■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

About the Authors���������������������������������������������������������������������������������������������������� lv


Acknowledgments������������������������������������������������������������������������������������������������� lvii
Introduction������������������������������������������������������������������������������������������������������������ lix


■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

Solving Errors with Variable Names��������������������������������������������������������������������������������� 2


Problem�������������������������������������������������������������������������������������������������������������������������������������������������� 2
Solution�������������������������������������������������������������������������������������������������������������������������������������������������� 2
The Code������������������������������������������������������������������������������������������������������������������������������������������������� 3
How It Works������������������������������������������������������������������������������������������������������������������������������������������� 3

Solving Reference Errors When Declaring Variables Inside a Function’s Scope������������� 3


Problem�������������������������������������������������������������������������������������������������������������������������������������������������� 3
Solution�������������������������������������������������������������������������������������������������������������������������������������������������� 4
The Code������������������������������������������������������������������������������������������������������������������������������������������������� 4
How It Works������������������������������������������������������������������������������������������������������������������������������������������� 4

Assigning Variables with the Let Statement��������������������������������������������������������������������� 6


Problem�������������������������������������������������������������������������������������������������������������������������������������������������� 6
Solution�������������������������������������������������������������������������������������������������������������������������������������������������� 6
The Code������������������������������������������������������������������������������������������������������������������������������������������������� 6
How It Works������������������������������������������������������������������������������������������������������������������������������������������� 7

vii
■ Contents

Assigning Constants with the Const Statement��������������������������������������������������������������� 7


Problem�������������������������������������������������������������������������������������������������������������������������������������������������� 7
Solution�������������������������������������������������������������������������������������������������������������������������������������������������� 8
The Code������������������������������������������������������������������������������������������������������������������������������������������������� 8
How It Works������������������������������������������������������������������������������������������������������������������������������������������� 8
Creating and Using Literals���������������������������������������������������������������������������������������������� 8
Problem�������������������������������������������������������������������������������������������������������������������������������������������������� 9
Solution�������������������������������������������������������������������������������������������������������������������������������������������������� 9
The Code������������������������������������������������������������������������������������������������������������������������������������������������� 9
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 10
Creating Types Using Their Constructors������������������������������������������������������������������������ 10
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 10
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 10
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 10
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 11
Determine If a Variable Has Been Defined Using an Equality Operator�������������������������� 11
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 11
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 11
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 11
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 12
Determining If a Variable Has Been Declared Using typeof( )����������������������������������������� 12
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 12
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 12
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 12
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 13
Determining If a Function Defines and Returns a Value������������������������������������������������� 13
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 13
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 13
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 13
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 15

viii
■ Contents

Determining If a Defined Variable Has a Value Using Equality Operators�������������������� 15


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 15
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 16
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 16
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 17

Performing Operations If a Defined Variable Has a Value����������������������������������������������� 17


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 17
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 17
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 17
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 18

What’s the Difference Between Null and Undefined?���������������������������������������������������� 18


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 18
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 18
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 19
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 19

Coercing a Boolean Variable Using the Boolean Constructor����������������������������������������� 19


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 19
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 19
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 20
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 20

Determining If a Boolean Variable Is Initialized�������������������������������������������������������������� 20


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 20
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 21
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 21
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 22

Valid Representations of the False and True Values������������������������������������������������������� 22


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 22
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 22
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 22
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 24

ix
■ Contents

Coercing a String Using the String Constructor������������������������������������������������������������� 24


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 24
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 24
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 24
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 25

Determining If a Variable Is a String������������������������������������������������������������������������������� 25


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 25
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 25
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 25
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 26

Coercing a Numeric Value Using the Number Constructor��������������������������������������������� 26


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 26
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 26
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 26
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 27

Creating a Numeric Value Using Number Literals���������������������������������������������������������� 27


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 27
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 27
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 28
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 29

Determining If a Defined Variable Is a Number�������������������������������������������������������������� 29


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 29
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 29
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 29
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 30

Dealing with NaN and Infinity����������������������������������������������������������������������������������������� 30


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 30
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 31
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 31
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 32

x
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
■ Contents

Generating a Date Using the Date Object����������������������������������������������������������������������� 32


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 32
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 32
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 32
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 33

Generating a Date with a Date String����������������������������������������������������������������������������� 33


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 33
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 33
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 33
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 34

Determining If a Defined Variable Is a Date�������������������������������������������������������������������� 34


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 34
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 35
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 35
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 35

Creating an Object and Assigning Properties����������������������������������������������������������������� 36


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 36
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 36
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 36
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 37

Determining If a Defined Variable Is an Object��������������������������������������������������������������� 37


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 37
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 37
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 38
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 38

Determining If an Object Is an Instance������������������������������������������������������������������������� 38


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 38
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 38
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 39
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 40

xi
■ Contents

Determining an Object’s Direct Instance with the Constructor Property������������������������ 40


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 40
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 40
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 40
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 41
Determining If Something Is a Plain Object�������������������������������������������������������������������� 42
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 42
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 42
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 42
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 43
Creating an Array and Assigning and Retrieving Values������������������������������������������������� 43
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 43
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 43
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 43
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 44
Choosing Between Objects and Arrays�������������������������������������������������������������������������� 44
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 44
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 44
Creating a Regular Expression Literal���������������������������������������������������������������������������� 45
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 45
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 45
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 45
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 46
Injecting Variables into a String with Template Literals������������������������������������������������� 46
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 46
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 46
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 47
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 47


■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 Equivalent to Another Using the == Operator������������������������ 59


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 59
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 59
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 59
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 60

Determining If a Value Is Strictly Equal to Another Using the === Operator��������������� 62


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 62
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 62
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 62
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 63

Determining If a Value Is Not Equivalent to Another Using the != Operator������������������� 64


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 64
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 64
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 65
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 66

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 Addition (+) Operator to Coerce an Object to a Number���������������������� 71


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 71
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 72
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 72
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 72

Using the Unary Subtraction (-) Operator to Flip the Sign of a Number������������������������� 72
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 72
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 73
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 73
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 73

Using the Logical NOT (!) Operator to Toggle a Boolean Value��������������������������������������� 73


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 73
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 73
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 74
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 74

Deleting an Object, Property, or Array Element with the Delete Operator���������������������� 74


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 74
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 74
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 75
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 75

xv
■ Contents

Evaluating an Expression Without a Return Value with the Void Operator��������������������� 76


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 76
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 76
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 76
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 77

Determining the Type of a Variable with the typeof Operator����������������������������������������� 77


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 77
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 77
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 78
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 78

Using instanceof to Determine If a Variable Is an Instance of an Object������������������������ 79


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 79
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 79
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 79
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 81

Finding Properties in an Object with the in Operator����������������������������������������������������� 81


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 81
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 81
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 82
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 83

Using Logical AND (&&) for Combining Boolean Expressions in an if Statement,


with Short-Circuit Evaluation����������������������������������������������������������������������������������������� 83
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 83
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 83
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 83
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 84

Using Logical OR (||) Short-Circuit Evaluation in an if Statement����������������������������������� 84


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 84
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 84
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 85
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 86

xvi
■ Contents

Simplifying Variable Assignments Using the Conditional (?) Operator��������������������������� 86


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 86
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 86
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 86
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 87

Specifying Multiple Expressions Using the Comma Operator���������������������������������������� 88


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 88
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 88
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 88
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 89


■Chapter 3: Working with Strings������������������������������������������������������������������������� 91
Understanding Unicode Strings�������������������������������������������������������������������������������������� 91
Problem������������������������������������������������������������������������������������������������������������������������������������������������ 91
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 91
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 91
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 92

Using Special Characters (Escape Codes) in Strings����������������������������������������������������� 93


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 93
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 93
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 93
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 93

Comparing Two Strings for Equality������������������������������������������������������������������������������� 93


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 93
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 94
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 94
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 94

Determining a String’s Length���������������������������������������������������������������������������������������� 95


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 95
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 95
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 95
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 95

xvii
■ Contents

Concatenating Strings with the + Operator������������������������������������������������������������������� 96


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 96
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 96
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 96
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 96

Getting a Single Character from a String����������������������������������������������������������������������� 97


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 97
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 97
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 97
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 97

Creating a String of UTF Character Code Units with fromCharCode( )���������������������������� 98


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 98
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 98
The Code����������������������������������������������������������������������������������������������������������������������������������������������� 98
How It Works����������������������������������������������������������������������������������������������������������������������������������������� 99

Creating a String of UTF Code Points with fromCodePoint( )������������������������������������������ 99


Problem������������������������������������������������������������������������������������������������������������������������������������������������ 99
Solution������������������������������������������������������������������������������������������������������������������������������������������������ 99
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 100
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 100

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

Iterating Over a String’s code Units Using for...in��������������������������������������������������������� 103


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 103
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 103
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 103
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 103
Iterating Over a String’s Code Points Using for...of������������������������������������������������������ 104
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 104
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 104
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 104
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 105
Repeating a String with repeat( )���������������������������������������������������������������������������������� 105
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 105
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 105
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 105
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 106
Determining If a String Contains a Smaller String Using contains( )���������������������������� 106
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 106
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 106
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 106
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 107
Determining If a String Starts with a Smaller String using startsWith( )���������������������� 108
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 108
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 108
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 108
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 109
Determining If a String Ends with a Smaller String Using endsWith( )������������������������� 110
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 110
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 110
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 110
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 111

xix
■ Contents

Finding the Index of an Occurring Substring with indexOf( )���������������������������������������� 112


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 112
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 112
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 112
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 113

Finding the Index of the Last Occurrence of a Substring with lastIndexOf( )���������������� 113
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 113
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 113
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 113
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 114

Finding Many Matches of a Substring with match( )���������������������������������������������������� 114


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 114
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 114
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 115
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 115

Replacing Parts of a String with replace( )������������������������������������������������������������������� 115


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 115
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 115
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 116
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 116

Searching a String Using a Regular Expression with search( )��������������������������������������� 116


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 116
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 117
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 117
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 117

Getting a Substring Form a String with slice( )������������������������������������������������������������� 118


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 118
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 118
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 118
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 118

xx
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
■ Contents

Splitting Strings with .split( )���������������������������������������������������������������������������������������� 118


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 118
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 119
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 119
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 119
Changing String Case with toUpperCase( ) and toLowerCase( )����������������������������������� 120
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 120
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 120
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 120
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 120
Stripping Blank Spaces with trim( )������������������������������������������������������������������������������ 121
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 121
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 121
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 121
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 121
Determining If a String “Comes Before” Another with localeCompare( )���������������������� 122
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 122
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 122
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 122
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 123
Counting the Occurrences of a Substring�������������������������������������������������������������������� 123
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 123
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 123
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 124
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 125
Padding a String with a Custom Function�������������������������������������������������������������������� 125
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 125
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 125
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 125
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 126

xxi
■ Contents

Truncating a String with a Custom Function���������������������������������������������������������������� 127


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 127
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 128
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 128
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 128
Making a ROT13 Cypher with a Custom Function�������������������������������������������������������� 129
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 129
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 129
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 129
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 130

Calculating the Levenshtein Distance Between Two Strings with a


Custom Function���������������������������������������������������������������������������������������������������������� 131
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 131
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 131
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 132
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 132


■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

Checking If a Value Is Not a Number���������������������������������������������������������������������������� 139


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 139
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 139
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 139
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 139
xxii
■ Contents

Formatting a Number to a Fixed Amount of Digits������������������������������������������������������� 139


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 139
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 139
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 140
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 140

Checking to See If a Number Is Finite�������������������������������������������������������������������������� 140


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 140
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 140
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 140
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 141

Checking If a Value Is an Integer���������������������������������������������������������������������������������� 141


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 141
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 141
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 141
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 142

Formatting Numbers for Date Time and Currency�������������������������������������������������������� 142


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 142
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 142
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 142
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 142

Creating a Random Number Generator������������������������������������������������������������������������ 143


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 143
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 143
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 143
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 143

Finding the Absolute Value of a Number���������������������������������������������������������������������� 143


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 143
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 143
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 144
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 144

xxiii
■ Contents

Using Math.max to Determine the Highest Number����������������������������������������������������� 144


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 144
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 144
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 144
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 145

Returning the Square Root of a Number���������������������������������������������������������������������� 145


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 145
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 145
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 145
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 145

Using Coercion and Performing Equations������������������������������������������������������������������� 145


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 145
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 145
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 146
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 146

What’s the Difference Between Math.floor() and Math.ceil()?�������������������������������������� 146


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 146
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 146
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 147
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 147

Returning a Number in Reverse����������������������������������������������������������������������������������� 147


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 147
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 147
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 147
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 148

Determining the Length of a Number��������������������������������������������������������������������������� 148


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 148
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 148
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 148
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 148

xxiv
■ Contents

Swapping Two Numbers Without a Temporary Variable����������������������������������������������� 149


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 149
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 149
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 149
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 149


■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

The sweet toned bell in the Observatory at Minnaviar rang


violently, and startled the students out of their usual calm and
placidity.
Kulmervan looked up from his studies. “What is it, my Waiko?”
said he in his own language to his friend.
“I know not, my Kulmervan. Let us go to the Turret Room, and
see.” The two astronomical students at the most important
meteorological college on the whole of Keemar, went swiftly up the
wide, marble stairway to their Djoh’s room. Before they were half
way up, the bell rang louder than before.
“Haste, my Waiko,” said Kulmervan. “The Djoh is anxious.” As
they reached the archway leading into the experimenting room, the
Djoh met them.
“At last,” said he testily. “At last you are come. I summoned you as
there is a most remarkable phenomenon registered by the sensitive
disc. After we recorded the destruction of the planet ‘Quilphis,’ you
will remember, we discovered a new comet or meteor that seemed to
have separated from the planet itself. We witnessed this
extraordinary ‘star’ whirling toward us, daily nearer and nearer. Our
learned Ab-Djohs consulted together as to the meaning of this
extraordinary thing. At last I was consulted, and by the aid of every
scientific means we possessed we tried to discover the substance of
this new moving orb. You recollect?”
“Yes, my Djoh,” answered Kulmervan, the senior student.
“Look,” said the Djoh triumphantly, and he led the way to a large
disc that stood in front of the large window. This disc was of glass,
and was connected by etheric pipes to a large telescopic tube fixed
outside the window. It was by the aid of this that the Keemarnians
studied the solar system, and learnt about the other worlds in the
sky.
As Kulmervan looked into the disc, he saw, by reflection, a peculiar
body suspended in the heavens—stationary it rested near Wirmir and
Kosli, the twin stars of Gorlan. “What is it?” he asked eagerly, while
Waiko, the younger student, stood silent, listening eagerly to the
conversation.
“It is the meteor of Marfaroo,” said he. “It is the strange body that
detached itself from Quilphis, when the life of that unfortunate
planet was run.”
“But it is still now, my Djoh.”
“The four Meevors have not yet risen, my son. In fourteen permos
from now, they will be bright and shining. When they are at their
full, they will draw that orb within our surrounding vapours. Then
we must direct our light rays upon it, and draw it within our
atmosphere. It is a wonderful thing, my son, and will aid us in our
knowledge of science. My theory is, that it is a minute portion of the
planet Quilphis itself. Oh, very small, hardly as big as the Rorka’s
palace; but the knowledge of its composition will help us in our
research. Take turn and watch with me, my sons, and at the right
moment we will direct our Ray upon it.”
Eagerly the students watched. The honour was great the Djoh had
put upon them, and they were eager to be present when the light of
the four full Meevors should shine upon the strange presence in the
sky.
“But the time the Kymo sinks to rest, my sons, the fourth Meevor
will be at the full, and we will watch the developments with interest.”
The three surrounded the little disc; the pale beams from the
Meevors shone distinctly on the glass; there was a movement—the
foreign body moved slowly toward them.
“The Ray,” cried the Djoh. “Summon the Ab-Djohs.”
Ten Ab-Djohs appeared at Waiko’s call. They were all dressed in
the green tunic and vest and short cloak—the symbol of their calling
as the highest astronomers in the land, bar one, the Djoh himself,
who wore a voluminous cloak and tall, conical hat in addition. The
wise men adjusted the focussing apparatus and directed the nozzle
toward Wirmir and Kosli. A whirring noise sounded—and then
suddenly shot out a most glorious ray. “When Kymo has risen but
four thoughts, the orb will be here,” announced the Djoh. “Waika, go
call Waz-Y-Kjesta. Tell him the Djoh has words of import to utter.”
Soon Waz-Y-Kjesta appeared. He was a handsome man, fair-
haired, long-limbed. He wore his blue toga as became him as Waz of
the air birds, the vessels which were used by the inhabitants of
Keemar to journey by the sky.
“Fetch in that strange star, O Waz,” said the Djoh. “Bring it to
earth, and I will await its arrival here.”
Waz-Y-Kjesta bowed low. “Your will shall be done, my Djoh,” said
he, and he went swiftly to the place where his air birds were housed.
“Mashonia,” said he to his Waz-Mar, or Lieutenant. “Order out six
air birds, we go on a mission for the Djoh.”
In a very short space of time, six beautiful “birds” rose from the
ground and skimmed toward their goal which was now approaching
very rapidly.
“My Waz,” cried Mashonia suddenly. “It is part of no planet that
we are approaching. See, there is glass in front, and men like
ourselves are looking toward us!”
“They are like us, yet unlike us,” said Waz-Y-Kjesta. “They are
habited in sombre clothing—they look dark and gloomy.”
“Where can they come from?” asked Mashonia wonderingly. “All
sons of Keemar would signal us. They are strangers from another
world, I fear.”
Gradually they circled round the Argenta, and brought her safely
to the ground. They watched the lifting of the shutters curiously. This
was indeed the strangest “air bird” they had ever seen. When Sir
John gave his wild cry, the Keemarnians realized that the strangers
who had come in so wonderful a manner to their land, had suffered
acutely. “Send for six Bhors,” said Waz-Y-Kjesta quickly, “these
friends are ill.”
In the shortest space of time, the Bhors, the Keemarnian carriages,
appeared. They were comfortable litters like vehicles, laden with rugs
of silk and downy cushions. Above were canopies of silk which
shaded the occupants, who swung hammock wise from a wheeled
frame, into the shafts of which were harnessed magnificent colis—
beasts very similar to Shetland ponies, only with long curly hair.
At a command from Waz-Y-Kjesta, Mashonia and another leapt
nimbly over the bulwarks of the Argenta, and without a word, in turn
carried all the erstwhile prisoners of the airship, and placed them on
cushions in the comfortable Keemarnian equipages. As Alan was
carried past the Waz, he murmured feebly. “A guard for the Argenta,
please.”
A look of surprise passed over the Keemarnian’s face. “What
meanest thou?” he asked.
“A guard,” urged Alan. “The Argenta contains all our possessions.”
“A guard?” answered Kjesta. “Nay, why should we do that? It is
safe there. It does not belong to us. Fear not, no one will touch it, my
friend.”
Gently the colis stepped out, drawing easily the Bhors and their
occupants. “Drive to the palace of the Jkak,” said Waz-Y-Kjesta. “We
must acquaint him first with the news of the arrival of these
strangers.”
The weary travellers saw nothing of the country through which
they passed. They were too weary and worn to raise themselves on
the cushions and look around. The cool breeze swept across their
faces and refreshed them, so they were content to remain as they
were and not think or worry about the future.
A runner was sent before to acquaint the Jkak of their near
approach, and as they stopped at his beautiful palace, men came out,
unhooked the hammock part of the Bhors, and carried the occupants
into the Jkak’s presence. He was awaiting them in the cool reception
hall, and regal and patriarchal he looked, in his robe of loose green
silk, with his golden fillet low upon his brow.
“My brothers,” said he in a low musical voice. “Welcome to
Keemar, the land of all good. Eat first from yonder viands. They will
revive you.”
Trays daintily laden with food and wine were placed before the
hungry travellers. The Jkakalata, consort to the Jkak, attended to
Mavis. “A child,” said she, “and a woman, too. Come, Persoph,” to
her husband, “give me that glass of friankate—it will revive her.” She
moistened Mavis’s lips with the fragrant wine—Mavis opened her
eyes, and as she looked at the kindly woman’s face, she burst into
tears. “Who are you?” she cried.
“I am Mirasu, the Jkakalata,” she replied. “Drink this, it will do
you good.”
Mavis drank long of the sweet liquor, and ate the strange fruits
that were placed before her. Alan, as usual, was the first to recover
and made a movement as if to rise from the Bhor.
“Nay,” said Persoph. “Do not move, I beg you. Rest, and later you
can tell us your story.” Then he turned to Desmond. “She with the
babe—she is yours?”
“How did you know?” asked the perplexed husband.
“By the look in your eye when my Mirasu handled your babe,” said
the wise old man sagely. “It was the look of possession.”
“Yes, she is my wife,” said Desmond.
“Wife—ah! that is the word. Now rest among the cushions of the
Bhors. Rooms are prepared for you. Sleep, my friends, until the
Kymo rises twice again. Then refreshed and strong we will welcome
you among us, and listen with interest to your story.”
The Jkak’s palace was of a glorious green marble, highly polished.
In the entrance hall was a huge fountain. Six beautiful maidens, their
garments chiselled out of coloured marble, held large shells from
which poured water into the basin beneath. The figures were life size,
and gracefully moulded. Lovely water flowers grew all around, and
coloured fish swam in and out among the pebbles and plants.
Up a wide stairway, which branched out into large galleries, the
strangers were carried, the Jkak himself leading the way, as if he
were doing homage to the Rorka himself. They wended their way
through a narrower passage which widened out again into a spacious
loggia. In the very centre of this space four malachite pillars, highly
polished, supported a crystal shell out of which poured sparkling
waters into a pond beneath. There were six doors round the loggia; at
the first the Jkak stopped, opening it himself, led the way in. With
gentle hands Desmond and Mavis were transferred to soft, downy
beds. “Rest, my friends, and sleep until Morkaba brings you wine
and food.” Then the other three were taken to separate sleeping
apartments, where their weary limbs rested in contentment on the
soft, downy cushions.
Desmond and Mavis’s room was perhaps the largest—a glorious
room with a wide balcony upon which were growing the most
beautiful creepers and plants—with wonderful perfumes and flowers.
An enormous four poster bed stood in the centre of the room, with its
back immediately in front of the door. A canopy of silk was overhead;
there were no sheets or blankets upon it, but there was an abundance
of cushions, and silken rugs of all hues. Easy chairs, plenty of mirrors
and a dressing table furnished the room. The walls were of a polished
pale pink marble, and the fittings, tapestries and silken hangings
were all of colours that blended and made one harmonious whole. All
the other rooms were similar, except in the colouring, and on the
polished marble floors were spread rugs of exotic colours.
A silver bell tinkled! To Mavis, it sounded like the Angelus on a
summer morning. She opened her eyes; again the bell sounded.
“Where am I?” she cried, and with sudden remembrance. “Baby—
where’s Baby?”
Desmond woke. “Where’s Baby, Dez?” she asked again piteously,
and even as she spoke she heard the sound of a tiny chuckle, and by
her side on a bed, the miniature of the one she was on, lay her baby,
crooning with delight. The bell tinkled again. Desmond went to the
door and opened it slightly. A smiling girl was outside with a table on
wheels. “Your mushti,” said she wheeling it toward him.
“To eat?” queried Desmond.
“Of course. It is pleasant on the ‘vala,’ outside among the flowers—
have it there with your friends.”
“Thank you. It’s breakfast, Mavis,” said Desmond. “Look out on
the balcony and see if Uncle John is there.”
Mavis was almost too bewildered to ask any questions, and
obeyed. There was a tiny gate dividing their balcony from the next,
and she went through. “Uncle John,” she called softly.
Sir John, Alan, and Masters appeared at the window of the next
room.
“You’re awake then?” laughed Alan.
“Yes.”
“Have you had any food?” asked Desmond.
Alan laughed. “A table each—and chock full. Shall we wheel ours
along and all have it together?” In a trice the six were sitting down to
the first real meal they had had since they had so miraculously
escaped from the end of the world.
The tables were of different coloured glass, and were laden with
food very different from that to which they had been accustomed.
There were jugs full of steaming liquid, neither tea, coffee, nor cocoa,
but with a reminiscent flavour of all three, and extremely refreshing.
There were wines—fruits whole, and fruits compote. There were
cereals served almost like porridge, and there was bread too. Bread
and tiny, crisp rolls, biscuits sweet and biscuits plain, and pats of
golden butter. It was a delightful meal, refreshing, invigorating, and
so different from the stodgy, unwholesome tinned meats they had
been living on for so long. There was also a tiny tray for the baby—a
bowl of fresh new milk and some rusks. A plate of a kind of
arrowroot mixture was greatly appreciated by little John Alan, who
cried out “More—pese, mum, more.”
“The little beggar likes it,” said Sir John. “He appreciates the
change too. Well, here we are all on land again at last, and among
friends.”
“What are you going to do?” asked Mavis.
“We’ll throw ourselves on the mercy of the Jovians of course; make
up our minds to settle down in a new world, and live the remainder
of our lives in peace and contentment.”
“Shan’t we ever go home again?” Mavis’s eyes widened, and she
looked imploringly at the others. The truth was forced on her mind at
last. She had no home! Gone were all her pretty possessions—gone
her trinkets, her books, her silver. Gone also her delicate trousseau—
her frocks, lingerie, jewels.
Everything was gone. The world itself had vanished.
“Now, my dear,” said Sir John. “We must acclimatize ourselves to
this new life. After, all, we can easily do that. We have been treated as
honoured guests, so I must speak to the Jkak, and find out our future
standing in this world.”
“They speak English!” said Alan wonderingly “How is that? Surely
we are the first English people who have found their way here? There
can’t be a colony of Britishers in Jupiter!”
The bell sounded again, and Alan went to the door. Waz-Y-Kjesta
stood outside. “The Jkak is eager to see you,” said he. “If you feel
strong enough and sufficiently rested, come with me and I will lead
you to him.” They followed him down the stairs to the entrance hall,
and through into a spacious apartment.
“The Reception Room,” said the Waz. “The Jkak wishes not to be
on formal terms with you—he bade me bring you to his garden
room.”
Through a doorway they went and out into the most glorious
garden they had ever seen. Fountains splashed in the sunlight—tiny
brooks gurgled over white stones, as they wound round beds of
flowers. There was a riot of colour in this wonderful garden—
glorious, flowering trees and shrubs abounded—creeper-covered
archways were everywhere, and at the further end they could see a
creeper-covered arbour, hung with exotic blooms. Inside this were
easy chairs, settees and comfortable lounges. The Jkak, and Mirasu,
his Jkakalata, were seated there awaiting their arrival, and rose to
greet them.
“Now tell us your story,” said the Jkak, “for wonderful it must be.”
“First,” said Alan, who at Sir John’s request, acted as spokesman,
“how is it you can understand our language? Surely English isn’t
spoken here?”
“English?”
“Yes. We are English. We come from that part of our world that
was known as England, you know.”
“We have the ‘gift of tongues’ my friend,” said the Jkak. “Until we
spoke to you, we had never before heard your tongue, but the
moment you spoke we understood. I cannot describe our gift—it just
—is. We of Keemar all speak one tongue. No confusion is here. Until
you came, we had never had the opportunity to benefit from this gift
we all believed we possessed. To-day, all Keemarnians are thanking
Mitzor, the Great White Glory and Tower of Help, for His
graciousness in having conferred upon us this gift, and for allowing
us to have the means given us for using the ‘gift of tongues’. We
understand, all of us. We may not understand every expression you
utter, for things are different in other worlds, and we ourselves no
doubt possess peculiarities of our own—still we can converse freely
with you.”
“It is a wonderful gift to possess,” said Sir John.
“Now your story,” insisted the Jkak gently.
So Alan told the whole story of his life since the time when he and
Desmond first went to Marshfielden. He told of the Light, and the
people of Kalvar—of their wonderful escape from the bowels of the
earth, and of the end of the world.
“So Quilphis is no more,” said the Jkak. “Indeed, we witnessed its
destruction, and thought that your airship was part of the planet
itself. And so,” he went on, “you believe that the end of the world was
caused through the failure of the fire in the centre of the earth?”
“I feel sure of it,” said Alan. “During our stay in Kalvar, we noticed
that the Fire grew daily less and less. And the purple people
prophesied that when the Fire went out, then would come the end of
the world. I think that, in its last dying gasp, it tried to get a new
lease of life. In its gigantic death struggle, it burst its bonds, and
earthquakes, volcanoes, and water spouts were the result.”
“Oh, it was horrible,” said Mavis shuddering.
“And your ship—the one you sailed in—you must invite me to see
it,” said the Jkak.
“Why, of course,” said Sir John. “Have you not been?”
“It is not mine,” replied the Jkak. “It would be an impertinence to
pry into your affairs without an invitation. Now, with regard to
yourselves. I must see that you go to Hoormoori and pay your
respects to our Rorka. Hoormoori is the chief place in this world of
ours; it is there that our Rorka has his palace.”
“Rorka?” asked Mavis “What is that?”
“Our Rorka rules over the whole of Keemar.”
“Have you only one Rorka or King over the whole of Keemar?”
asked Sir John.
“Why, of course. Why should we have more?” asked Mirasu
smiling. “Keemar is one world—with one Rorka. Then we have one
hundred Jkaks, and one thousand Moritous—that is enough, surely,
to govern a world?”
“Are you only one nation then?”
“Naturally. We are all Keemarnians—just one great nation, divided
into many families. We all speak the same language—all worship in
the same fashion Mitzor, the Great White Glory and Tower of
Strength, and all live in peace, friendship, and harmony, one with
another. But now my friends, strangers though you are, you are
welcome here. I will put at your disposal houses and serving men.”
“We possess nothing,” said Sir John. “We have no property, no
valuables—nothing but the Argenta. How shall we repay your
kindness to us?”
“Repay?” said the Jkak, “nay, that is another, word I know not the
meaning of.”
“But,” began Alan.
“Nay, you are strangers in a strange world. It is our duty to make
you all feel at home here. I can see you were of high estate in your
own country—you must be of high estate here also. Know you, we are
wise in this land. Our Rorka is first, and his spouse, the Rorkata,
ranks second. Their offspring and nearest blood relations come next;
then come the Jkaks and Moritous; our Djohs and Ab-Djohs; the
Wazi, Captains of our air birds, our learned men and students, down
to the serving men and maids, and the builders of our homes and our
ships. From highest to lowest, all share ‘pro rata’ in the good things
of the world. We are all satisfied—the laws of our land have fixed the
rates that are to be paid to each household from the common fund. I
assure you, there will be enough and to spare for you.”
Masters spoke for the first time. “I am Sir John’s servant,” he
began.
“No,” corrected Sir John. “Masters is my faithful friend and
adviser.”
“Then you would like him to dwell in the same house with you?”
“Please,” said Sir John, “and my nephew Alan, also.”
“And you, no doubt,” went on the Jkak turning to Desmond, “you
would like to have apartments to yourselves.”
“Thank you,” answered Mavis for her husband and herself.
“Good. I will summon Waz-Y-Kjesta. There are several new houses
near at hand. Go with him—you can take your choice,” and with a
wave of the hand and a smile, they realized that they were dismissed
from the presence of the Jkak and his charming wife.
Waz-Y-Kjesta was hovering near and came toward them. He had
received his full instructions beforehand. “Come,” said he. “The
houses that are unoccupied are quite close—come and take your
choice.”
“How is it,” asked Alan, “that we can walk so easily now. When we
first came out on to the open deck of the Argenta, our limbs were as
heavy as lead. We could not walk an inch, and we were so top-heavy
we could hardly stand.”
“That is easy to explain,” replied the Waz. “Eight Kymos have risen
since you arrived here.”
“Kymos?” asked Mavis. The Keemarnian names puzzled her.
“Sun?” suggested Alan.
“Ah, you call it—sun. Yes, since you first came, the sun has sunk
seven times. You have slept—breathed in our air. While you were
sleeping, our men of science administered medicinal gases through
your nostrils. These gases lightened you—took from you the
heaviness of your earth. You will find no difficulty now,” and he led
the way through the garden to the most glorious street it was
possible to imagine.
“Now you will see our country,” he continued, “and compare it
with your own. You are not too tired?” he asked Mavis.
“No, of course not. I feel too excited. I want to see your beautiful
city—your beautiful country. May I first see that my baby is all
right?”
He gave the necessary permission, and soon she returned. “He is
sleeping peacefully,” said she. “Morkaba is watching over him. Now
I’m ready,” and they all went down the marble steps of the Jkak’s
palace, eager for their first sight of this new, strange land.
CHAPTER V
DEATH IN JUPITER

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.

You might also like