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

Download ebooks file JavaScript Recipes: A Problem-Solution Approach 1st Edition Russ Ferguson all chapters

JavaScript

Uploaded by

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

Download ebooks file JavaScript Recipes: A Problem-Solution Approach 1st Edition Russ Ferguson all chapters

JavaScript

Uploaded by

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

Experience Seamless Full Ebook Downloads for Every Genre 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/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook 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/

textboxfull.com

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

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

textboxfull.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/

textboxfull.com

wxPython Recipes: A Problem - Solution Approach 1st


Edition Mike Driscoll

https://textbookfull.com/product/wxpython-recipes-a-problem-solution-
approach-1st-edition-mike-driscoll/

textboxfull.com
MATLAB Recipes: a problem-solution approach 2nd Edition
Michael Paluszek

https://textbookfull.com/product/matlab-recipes-a-problem-solution-
approach-2nd-edition-michael-paluszek/

textboxfull.com

PrestaShop Recipes : A Problem-Solution Approach 1st


Edition Arnaldo Pérez Castaño (Auth.)

https://textbookfull.com/product/prestashop-recipes-a-problem-
solution-approach-1st-edition-arnaldo-perez-castano-auth/

textboxfull.com

Java EE 7 Recipes A Problem Solution Approach 1st Edition


Juneau Josh

https://textbookfull.com/product/java-ee-7-recipes-a-problem-solution-
approach-1st-edition-juneau-josh/

textboxfull.com

Java 9 Recipes: A Problem-Solution Approach 3rd Edition


Josh Juneau

https://textbookfull.com/product/java-9-recipes-a-problem-solution-
approach-3rd-edition-josh-juneau/

textboxfull.com

Spring 5 Recipes: A Problem-Solution Approach 4th Edition


Marten Deinum

https://textbookfull.com/product/spring-5-recipes-a-problem-solution-
approach-4th-edition-marten-deinum/

textboxfull.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
■ 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
■ 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
■ Contents

Using Bitwise AND (&) Operator to Get a Value of All Equal Bits in a 32-Bit Integer����� 159
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 159
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 160
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 160
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 160

Using Bitwise OR (|) Operator to Get a Value Positive Bits on One or Both Operands�� 161
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 161
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 161
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 162
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 162
Using the Bitwise XOR (^) Operator to Get a Value of Differing Bits in Each Operand�������� 163
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 163
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 163
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 163
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 164
Converting RGB Color to Hexadecimal and Back Using
the Bitwise Signed Shift (>>, <<) Operators and the Bitwise AND (&) Operator��������� 165
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 165
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 165
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 165
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 166
Creating, Editing, and Testing a Bit Field Flag Set Using Bitwise Operators����������������� 169
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 169
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 169
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 169
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 170


■Chapter 6: Dates and Times������������������������������������������������������������������������������� 173
Using the Date Object��������������������������������������������������������������������������������������������������� 173
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 173
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 173
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 173
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 173
xxvi
■ Contents

Getting Date and Time Information������������������������������������������������������������������������������ 174


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

Calculating User Age���������������������������������������������������������������������������������������������������� 175


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

Using the HTML5 Date Input Field to Make a Date Object�������������������������������������������� 175
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 175
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 175
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 176
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 176

Checking If Two Dates Are the Same���������������������������������������������������������������������������� 177


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

Working with getTimezoneOffset��������������������������������������������������������������������������������� 177


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 177
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 177
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 178
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 178

Formatting Date and Time�������������������������������������������������������������������������������������������� 178


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 178
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 178
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 179
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 179

xxvii
■ Contents

Calculating Days from a Certain Date�������������������������������������������������������������������������� 179


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 179
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 179
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 179
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 180

Checking If Your Date Is in a Range of Dates��������������������������������������������������������������� 180


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


■Chapter 7: Working with Arrays������������������������������������������������������������������������ 181
What Is an Array?��������������������������������������������������������������������������������������������������������� 181
Problem���������������������������������������������������������������������������������������������������������������������������������������������� 181
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 181
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 181
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 181

How Do You Access Elements in an Array?������������������������������������������������������������������ 181


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 181
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 182
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 182
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 182

How Do You Create a Multi-Dimensional Array?����������������������������������������������������������� 182


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

How Do You Initialize an Array with Values?����������������������������������������������������������������� 183


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

xxviii
■ Contents

What Is the Size of the Array?�������������������������������������������������������������������������������������� 183


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

How Do You Convert an Array to a String?������������������������������������������������������������������� 184


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

How Do You Add an Element to the End of an Array?��������������������������������������������������� 184


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 184
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 184
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 184
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 185

How Do You Add Items to an Array Within a Range?���������������������������������������������������� 185


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

How Do You Append an Array to the End of Another Array?����������������������������������������� 185


Problem���������������������������������������������������������������������������������������������������������������������������������������������� 185
Solution���������������������������������������������������������������������������������������������������������������������������������������������� 185
The Code��������������������������������������������������������������������������������������������������������������������������������������������� 185
How It Works��������������������������������������������������������������������������������������������������������������������������������������� 186

How Do You Reverse the Order of the Items in an Array?�������������������������������������������� 186


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

xxix
Random documents with unrelated
content Scribd suggests to you:
CHAPTER X
FOR JEWELLERS, CLOCK AND WATCH
MAKERS AND MERCHANTS

By long established custom, watches and the higher grade of clocks


form part of the jeweller’s stock, and he sells a few other articles of
utility, such as purses and bags, but to all intents and purposes he
shares with the artist and art-dealer the distinction of making a
living by adding pleasure to the lives of others. The very word
“jewelry” carries, in its root form, the idea of joy; and when a
Senwosri princess, 43 centuries ago, smiled happily as she raised her
brown arms to fasten the clasp of a new necklace, the jeweller of
Memphis on the Nile no doubt took his little profit, as the jeweller of
Memphis on the Mississippi takes his to-day, all the more gladly for
being, in the oriental phrase, a “Distributor of delights.” Sour
philosophers have always sneered at women for loving jewels, and
most of all for piercing their ears and noses to vary its display, but
the nose-ring that overhangs a thick Nubian lip is an expression of
the same charming instinct that makes a child diversify the
arrangement of her daisychains. And jewelry plays its part in the
higher emotions as well as in the pretty vanities; witness the
engagement ring, the marriage ring and all the uses, described in the
Britannica, of jewels as religious symbols.
Specimens The article Jewelry (Vol. 15, p. 364),
Reproduced by A. H. Smith, the official in charge of
the great jewel collection in the British
Museum, contains nearly a hundred illustrations, half of them on
plate paper, which include examples of every period and every
variety of the jeweller’s art, and these, with the illustrations in other
articles mentioned in this chapter, are so full of interest to the
jeweller’s customers that he ought really to keep his Britannica at his
place of business rather than at his house. It is, at any rate, amusing
to recall that in a speech made by the Editor-in-chief of the
Britannica, on the occasion of a banquet given to celebrate the
completion of the new edition, he remarked that when he had
chanced to take home the proof sheets of this article, to read them at
night, he carefully kept them out of his wife’s sight lest they might
suggest too tempting possibilities. The article divides modern jewelry
into three classes:
(1) objects in which gems and stones form the principal portions, and in
which the work in silver, platinum or gold is really only a means for carrying
out the design by fixing the gems or stones in the position arranged by the
designer, the metal employed being visible only as a setting;
(2) when gold work plays an important part in the development of the
design, being itself ornamented by engraving (now rarely used) or enamelling
or both, the stones and gems being arranged in subordination to the gold work
in such positions as to give a decorative effect to the whole;
(3) when gold or other metal is alone used, the design being wrought out by
hammering in repoussé, casting, engraving, chasing or by the addition of
filigree work, or when the surfaces are left absolutely plain but polished and
highly finished.
The “Personal The second of these three classes
Art” Movement includes the work which has
completely revolutionized the theory of
design, so far as the best class of trade is concerned, since the Paris
International Exposition of 1900 first drew general attention to the
exquisite creations of Lalique and his school. L. C. Tiffany, in the
United States, and Philippe Wolfers, in Belgium, have done more
than any designers other than the French to extend this new
movement; but in England, Germany, Austria, Russia and
Switzerland there has been a notable increase of individual effort and
purpose, and a recognition of the possibilities of personal art as at
any rate an important factor in the business. Side by side with this
development new standards have been established in mechanical
work. “Nearly every kind of gold chain now made is manufactured by
machinery, and nothing like the beauty of design or perfection of
workmanship could be obtained by hand at, probably, any cost.” The
article, equivalent in length to about 35 pages of this Guide, contains
a full review, amplified by the results of the most recent excavations
(some of them undertaken expressly for the archaeological purposes
of this edition of the Britannica) of the history of jewelry, Egyptian,
Assyrian, Mycenean, Greek, Etruscan, Roman, Merovingian, Oriental
and Renaissance.
Rings for Love Ring (Vol. 23, p. 349), of which Prof.
and Murder Middleton, long art director of the
South Kensington Museum, is the chief
contributor, is another copiously illustrated article. Among the
curious items of information it contains, there is the unromantic
origin of the engagement ring (which may be cited by the jeweller to
prove that it should always be a costly one), the ancient Romans
regarding it as a pledge to assure the donor’s fulfilment of his
promise; the fact that the modern rheumatism ring had its medieval
forerunner in the rings, blessed by the sovereign, which were worn as
a preservative against cramp; and the description of the old poison
rings, which were of two kinds: those merely affording, in the bezel, a
secret receptacle so that the poison might be always at hand for
suicide, and those provided with a hollow point to which, on
touching a spring, the venom ran as in a snake’s fang, so that the
murderer could give a fatal scratch while shaking hands with his
victim. Brooch (Vol. 4, p. 641) traces, with many illustrations of
typical specimens, the “fibula” or safety pin from its origin in Central
Europe during the Bronze Age, through the modifications which
introduced the bow shape, providing space for thicker folds of cloth,
to the modern ornament. The long brooch is not a new fashion, for
silver brooches no less than 15 inches in length have been found in
Viking hoards of the 7th, 8th and 9th centuries. Ear-ring (Vol. 8, p.
798) describes ear “ornaments” of the most grotesque size. In Borneo
the hole in the ear lobe is stretched to a calibre of 3¾ inches, but the
Masai tribes in equatorial Africa far outdo this, stretching the lobes,
year after year, until they can wear stone ear-plugs weighing 2 lbs. 14
ozs. each, with a diameter of 4½ inches; and they thus achieve the
supreme elegance of making the two long flaps of flesh meet above
their heads. It is also curious to note the custom of some oriental
tribes of wearing one ear-ring only. Bracelet (Vol. 4, p. 359)
describes the three distinct models worn by the Israelites, all of
which the Authorized Version calls “bracelet,” although the original
Hebrew has separate names for them. Armlets have always been
conspicuous in the regalia of Eastern kings, and the pair captured at
Delhi and taken to Persia by Nadir Shah in 1739 contain jewels
valued at more than $5,000,000, including the famous “Sea of
Light” diamond, which, although it weighs only 186 carats as against
the 516½ of the largest fraction into which the Cullinan stone was
cut, is unique as possessing the finest lustre of any known specimen.
The 24 plate illustrations in the article Scandinavian Civilization
(Vol. 24, p. 287), by Miss B. S. Phillpotts, show some exquisite
designs of clasps, collars and pins exhumed in Denmark, Norway and
Sweden, and supposed by some authorities to antedate the oldest
Egyptian jewelry.
Precious Metals The article Gold (Vol. 12, p. 192) is a
thorough workshop treatise, as well as
a detailed study of existing mines and of the influence their
production exerts upon the “price,” if it can be so called, of a metal
which is its own standard of value. Silver (Vol. 25, p. 112) and
Platinum (Vol. 21, p. 805) are treated with similar
comprehensiveness. The articles Alloys (Vol. 1, p. 704), Assaying
(Vol. 2, p. 776), Metal (Vol. 18, p. 198), Metallography (Vol. 18, p.
202), and Metallurgy (Vol. 18, p. 203), all by noted authorities, are
full of information useful to the jeweller. Metal-Work (Vol. 18, p.
205), fully illustrated, incidentally touches upon the art of the silver-
and gold-smith; and this branch of the subject is also treated in such
articles as Plate (Vol. 21, p. 789), with over 30 typical illustrations—
a most interesting historical account, by several well-known experts,
of works in gold and silver which belong to any class other than those
of personal ornament and coins; and Drinking Vessels (Vol. 8, p.
580), illustrated, by Dr. Charles H. Read of the British Museum,
which discusses gold and silver cups. Mention must also be made of
the description of American work in precious metals before the time
of Christopher Columbus, in the section Archaeology of the article
America (Vol. 1, p. 812), by the late Dr. O. T. Mason, of the National
Museum, Washington; also of Mexico, Ancient Civilization (Vol. 18,
p. 335), by the famous ethnologists, Dr. E. B. Tylor of Oxford and Dr.
Walter Lehmann, of the Royal Ethnographical Museum, Munich;
Egypt, Ancient Art (Vol. 9, p. 73), by W. M. Flinders Petrie; Greek
Art (Vol. 12, p. 470), illustrated, by Dr. Percy Gardner, of Oxford;
Roman Art, Work in Precious Metals (Vol. 23, p. 483), illustrated,
by H. Stuart Jones, director of the British School at Rome; Japan,
Art, Sculpture and Carving (Vol. 15, p. 176), by Capt. Frank Brinkley,
author of A History of the Japanese People; and China, Bronzes
(Vol. 6, p. 215), by C. J. Holmes, formerly Slade professor of fine art
at Oxford.
Filigree (Vol. 10, p. 343) describes the delicate jewel work of
twisted gold and silver threads, and also the “granulated” work which
consists of minute globules of gold soldered to form patterns on a
metal surface. In India the filigree worker has retained the patterns
used by the ancient Greeks and works in the same way they did.
Wandering workmen are given so much gold, coined or rough. This
is weighed, heated and beaten into wire, and worked in the courtyard
or on the verandah of the customer’s house. The worker reweighs the
complete work when finished and is paid at a specified rate for his
labor. Repoussé (Vol. 23, p. 108), by M. H. Spielmann, editor
Magazine of Art; Chasing (Vol. 5, p. 956) and Inlaying (Vol. 14, p.
574) are other articles dealing with certain processes in jewel work.
The jeweller also must not overlook two superb articles, Medal (Vol.
18, p. 1), illustrated, by M. H. Spielmann, and Numismatics (Vol. 19,
p. 869), which is by three specialists, and is most fully illustrated by
designs inviting practical use. Enamel (Vol. 9, p. 362), illustrated, by
Alexander Fisher, author of The Art of Enamelling on Metals, goes
very fully and practically into this interesting subject, which is
further discussed in Japan, Cloisonné Enamel (Vol. 15, p. 189).
Mosaic (Vol. 18, p. 883), illustrated, by Professor Middleton and H.
Stuart Jones, deals in part with the ornamentation of jewelry by this
method. In Brazing and Soldering (Vol. 4, p. 463) the composition
of silver solder used for jewelry is described, and in Cement there is
an account of Jeweller’s or Armenian Cement (Vol. 5, p. 659).
Precious Stones The article Gem treats the subject in
two sections, of which the first (Vol. 11,
p. 560), by F. W. Rudler, of the Museum of Practical Geology,
London, deals with Mineralogy and General Properties. Here are
discussed hardness, specific gravity, crystaline forms and cleavage,
colour, refraction, chemical composition, etc., and there is an
interesting section on superstitions in regard to gems, the medical
and magical powers with which they were reputed to be endowed.
These beliefs are very remarkable, and it has even been suggested by
archaeologists that jewelry did not have its origin so much in a love
for personal decoration, as in the belief that the objects used
possessed magical virtue. The article Mineralogy (Vol. 18, p. 509),
by L. J. Spencer, of the British Museum, and editor of the
Mineralogical Magazine, will be found especially valuable for
reference in the workshop. It gives, among other things, the scale of
hardness, and nomenclature and classification of minerals. The
crystal formation of gems as well as their optical properties—
characteristics by which the genuineness of precious stones may be
tested—are discussed and explained in the article Crystallography
(Vol. 7, p. 569), with over 100 illustrations, also by L. J. Spencer. The
cutting of gem stones is treated under Lapidary and Gem Cutting
(Vol. 16, p. 195), by Dr. George F. Kunz, the famous gem expert to
Tiffany & Co., New York,—an article of uncommon historical interest
and practical value, in which diamond cutting is considered at much
length.
The second section of the article Gem, Gems in Art (Vol. 11, p.
562), by Dr. A. S. Murray, the famous British archaeologist, and A.
H. Smith, gives an account of precious stones engraved with designs.
The illustrations show more than 90 examples, including Cretan and
Mycenaean intaglios, Greek, Phœnician and Etruscan scarabs and
scarabæoids, cameos, seals, Oriental, Christian, and modern gems.
This subject is further discussed in separate articles, such as Scarab
(Vol. 24, p. 301), by Dr. F. Ll. Griffith, the Egyptologist, an account of
the designs which, originating in Egypt during the Fourth Dynasty,
have exercised a lasting influence on the design and shape of gems;
Cameo (Vol. 5, p. 104), Intaglio (Vol. 14, p. 680), Seals (Vol. 24, p.
539), illustrated, by Sir E. Maunde Thompson, formerly principal
librarian, British Museum, as well as in the articles on ancient and
Oriental civilizations, already mentioned.
Synthetic Stones The artificial duplication of certain
gems by chemical processes which
yield products identical in composition and physical properties with
the natural stones is a subject of growing importance to the jeweller,
and the latest developments are described in Gem, Artificial (Vol.
11, p. 569), by Sir William Crookes. This famous chemist and
authority on precious stones does not hesitate to declare that
although the artificial diamonds so far produced have been
microscopic in size, scientists have now found the right method and
that “there is no reason to doubt that, working on a larger scale,
larger diamonds will result.” The artificial production of rubies,
sapphires, Oriental emeralds, amethysts, topazes and zircons is also
discussed. Descriptions of the several gem stones are found under
their respective headings, for example Diamond (Vol. 8, p. 158),
illustrated, by H. A. Miers, principal of the University of London, and
former editor of the Mineralogical Magazine. Here are given its
scientific characters, its uses (especially for faceting softer precious
stones), distribution, and mining, and the wonderful history of the
most famous diamonds of the world. Ruby (Vol. 23, p. 812), the most
valued of gem stones, is often called “Oriental ruby” to distinguish it
from Spinel (Vol. 25, p. 684), an aluminate stone of inferior
hardness, density and value. It is interesting to note that many
historic stones described as monster rubies were really spinels. The
great ruby set in the Maltese Cross in front of the Imperial State
Crown of England is a spinel. Sapphire (Vol. 24, p. 201) was known
to the Greeks as “hyacinthus,” and the present name was formerly
applied to lapis lazuli. Asteria or Star Stone (Vol. 2, p. 792) tells
how the luminous star comes to be seen in sapphires, rubies and
topazes. The name Emerald (Vol. 9, p. 332) is used for a number of
stones, of which the most valued is not a true emerald at all; see
Corundum (Vol. 7, p. 207). The same is true of the Topaz (Vol. 27, p.
48), the more prized Oriental topaz being a yellow corundum, harder
and denser than the stone from which it takes its name. “Scotch” or
“Spanish” topazes are yellow or smoke-tinted quartz, or cairngorm.
The Amethyst (Vol. 1, p. 852) is violet or purple quartz, and the
sapphire of a purple colour is often called an Oriental amethyst. The
many varieties of the beautiful Zircon (Vol. 28, p. 989), such as
Hyacinth (Vol. 14, p. 25) and Jargoon (Vol. 15, p. 276) are carefully
described and distinguished. These valuable articles on the precious
stones have been contributed by F. W. Rudler, of the Museum of
Practical Geology, London. Pearl (Vol. 21, p. 24) discusses the
results of the latest researches on the cause of pearl formation, and
gives a graphic account of pearl-fishing.
Semi-Precious The material in the Britannica on the
Stones semi-precious stones is as complete.
There are many articles, specified in
the list at the end of this chapter. Alexandrite (Vol. 1, p. 576) is
remarkable for its property of appearing dark green by daylight, and
red by candle-light, which makes it especially popular in Russia
where green and red are the military colors; Chrysoberyl (Vol. 6, p.
320), of which alexandrite is a variety; Chrysolite (Vol. 6, p, 320),
often mistaken for chrysoberyl; Peridot (Vol. 21, p. 147), like
chrysolite, a variety of olivine; Beryl (Vol. 3, p. 817), much prized by
the ancients as a gem stone, and of which the Emerald (see above)
and the Aquamarine (Vol. 2, p. 237) are the chief “precious”
varieties; Tourmaline (Vol. 27, p 103), the remarkable stone of as
much interest to the physicist as to the jeweller, on account of its
optical and electrical properties; and Rubellite (Vol. 23, p. 804), its
much prized red variety Garnet (Vol. 11, p. 470), together with
Almandine (Vol. 1, p. 712), which, when cut with a convex face is
known as carbuncle; Cinnamon-Stone (Vol. 6, p. 376), the light red
garnet, so easily mistaken for a variety of zircon (the article tells how
to distinguish them); Demantoid (Vol. 7, p. 979), the green garnet
from the Urals, and Pyrope (Vol. 22, p. 695), usually known as
Bohemian garnet; Jade (Vol. 15, p. 122), which occupies in China the
highest place as a jewel, and whose many varieties are here clearly
distinguished; Jet (Vol. 15, p. 358); Haematite (Vol. 12, p. 804);
Moonstone (Vol. 18, p. 807); Cat’s-Eye (Vol. 5, p. 537), a term
applied to several distinct minerals of which Crocidolite (Vol. 7, p.
477) has recently become very popular; Opal (Vol. 20, p. 120), an
article in which the brilliant flashes of colour in this stone are
explained; Quartz (Vol. 22, p. 715), with its many ornamental
varieties such as Agate (Vol. 1, p. 368), Amethyst (Vol. 1, p. 852),
Aventurine (Vol. 3, p. 54), Bloodstone (Vol. 4, p. 85), Cairngorm
(Vol. 4, p. 952), Carnelian (Vol. 5, p. 365), Chalcedony (Vol. 5, p.
803), Chrysoprase (Vol. 6, p. 320), Heliotrope (Vol. 13, p. 232),
Mocha Stone (Vol. 18, p. 637), Onyx (Vol. 20, p. 118), Rock-
Crystal (Vol. 23, p. 433), Sard (Vol. 24, p. 209), and Sardonyx
(Vol. 24, p. 2.18).
Watches and The article Watch (Vol. 28, p. 362),
Clocks illustrated, by Lord Grimthorpe, the
great authority on watches and clocks,
and Sir H. H. Cunynghame, vice-president of the British Institute of
Electrical Engineers, is full of interest. There is a very valuable
historical account beginning with the invention of portable time
pieces in the 15th century. The parts of a modern watch are
described, with details as to the mainspring, different types of
escapement, the balance-wheel and hair-spring, compensation
adjustments and secondary compensation. Methods of correcting
temperature errors are discussed, and a simple means for
demagnetizing a watch which has been near a dynamo is given. The
proper materials used for jewelled bearings are described in the
articles Diamond, Corundum, etc. Lubricants (Vol. 17, p. 88)
contains a valuable paragraph on the properties and preparation of
the fluid oils used on the spindles of watches and clocks.
The article Clock (Vol. 6, p. 536) is by the same distinguished
authorities as Watch, with an additional section on Decorative
Aspects (p. 552), by James Penderel-Brodhurst. It is equivalent to 55
pages of this Guide and is fully illustrated. Among the topics
considered are the earliest clocks and their gradual improvement;
the essential components of a clock; the mechanics of the pendulum;
methods of compensation, including the use of the new nickel-steel
alloy—described in the article Invar (Vol. 14, p. 717)—the
barometrical error, and methods of counteraction; suspension of
pendulums; balance, anchor, dead, pinwheel, detached or free, and
gravity escapements; the remontoire systems for abolishing errors in
the force driving the escapement; testing of clocks; clock wheels;
striking mechanism; the watchman’s clock, church and turret clocks,
electrical clocks, miscellaneous clocks, including magical clocks and
other curious designs. The section on Decorative Aspects tells about
styles of cases and mountings, the origin and development of the
“grandfather” clock, etc. In connection with long-period clocks,
attention should be given to the new and ingenious, if not
commercially practical, device invented by the Hon. R. J. Strutt.
Electrified particles emitted by a radioactive substance separate two
strips of gold leaf, and these, falling together after the charge has
been conducted away upon contact with metal, are extended again,
the process being constantly repeated. If some way could be found to
utilize this motion to work an escapement, we should have a clock
that would go on indefinitely, since 1000 years must elapse before
even half the small amount of radium used has disappeared. A
description of this so-called “radium” clock will be found in
Perpetual Motion (Vol. 21, p. 181).

ALPHABETICAL LIST OF ARTICLES IN THE


ENCYCLOPAEDIA BRITANNICA OF SPECIAL INTEREST
TO MANUFACTURERS OF AND DEALERS IN JEWELRY,
CLOCKS, AND WATCHES

Agate
Aigrette
Aiguillette
Albite
Alexandrite
Alloys
Almandine
Amazon-stone
Amber
America, Archaeology
Amethyst
Andalusite
Anhydrite
Apatite
Apostle Spoons
Aquamarine
Arabesque
Arts and Crafts
Assaying
Asteria, or Star-stone
Aventurine
Axinite
Azurite
Bead
Benitoite
Beryl
Beryllonite
Biddery
Bloodstone
Bort
Bracelet
Brazing and Soldering
Britain, Ornaments
Bronzite
Brooch
Cairngorm
Cameo
Campani-Alimenis, M.
Carbonado
Carnelian
Cat’s-eye
Cellini, Benvenuto
Cement
Chain
Chalcedony
Chasing
Chessylite
China, Art
Chrysoberyl
Chrysolite
Chrysoprase
Cinnamon-stone
Clock
Collar
Congreve, Sir William
Coral
Corundum
Costume
Cressent, Charles
Crocidolite
Cross
Crown
Crystallography
Cyanite
Demantoid
Diallage
Diamond
Dioptase
Drinking Vessels
Dumortierite
Ear-ring
Egypt, Ancient Art
Electroplating
Emerald
Emery
Enamel
Epidote
Euclase
Felspar
Filigree
Finiguerra, Maso
Fluorescence
Fluor-spar
Franklin, Benjamin
Galileo Galilei
Garnet
Gem
Gem, Artificial
Gold
Gold beating
Göthite
Gouthière, Pierre
Greek Art
Grimthorpe, 1st Baron
Haematite
Hiddenite
Hyacinth, or Jacinth
Hypersthene
Inlaying
Intaglio
Invar
Iolite
Ivory
Jade
Japan, Art
Jargoon
Jasper
Jet
Jewelry
Knighthood and Chivalry
Kunzite
Labradorite
Lapidary and Gem Cutting
Lapis Lazuli
Leucite
Line-engraving
Lubricants
Malachite
Marot, Daniel
Meissonier, J. A.
Medal
Metal
Metallography
Metallurgy
Metal-Work
Mexico, Ancient Civilization
Microcline
Mineral Deposits
Mineralogy
Miniature
Mint
Mocha-stone
Monogram
Monteith
Moonstone
Morel-Ladeuil, Léonard
Mosaic
Nepheline
Niello
Numismatics
Oligoclase
Olivine
Onyx
Opal
Orthoclase
Palladium
Paste
Pearl
Peridot
Perpetual Motion
Phenacite
Phosphorescence
Plagioclase
Plate
Plated Ware
Platinum
Pollaiuolo
Prehnite
Pyrope
Pyroxene
Quartz
Regalia
Repoussé
Ring
Rock-crystal
Roman Art
Rubellite
Ruby
Sapphire
Sard
Sardonyx
Scandinavian Civilization
Scarab
Seals
Sheffield Plate
Silver
Sphene
Spinel
Spodumene
Staurolite
Sunstone
Tassie, James
Tiffany, C. L.
Time, Measurement of
Time, Standard
Topaz
Tourmaline
Turquoise
Variscite
Vesuvianite
Watch
Weighing Machines
Weights and Measures
Wyon, Thomas
Zircon
Zoisite
CHAPTER XI
FOR MERCHANTS AND MANUFACTURERS
OF ELECTRICAL MACHINERY AND
SUPPLIES

Construction and Electrical machinery and supplies


Operation include three main groups of
appliances: The apparatus by which
electricity is originally generated; the apparatus by which current is
transmitted and, if necessary, modified before it is used; and the
infinitely various appliances for its final employment. In connection
with any one of the latter, information may be needed as to its
structure and its mechanical or electrochemical method of operation,
or as to its uses, and in the treatment of these two aspects of a vast
number of subjects the advantages of the encyclopaedic plan of the
Britannica are obvious. One article will explain the method by which
the same principles are applied to a number of different machines.
Another article will deal with a group of appliances all used for
similar purposes; and a reference to the Index of 500,000 entries
(Vol. 29) will at once guide the reader who turns to the name of any
electrical appliance to either kind of information he desires at the
moment, whether he wants to know how the machine is made and
operated, or what kind of work it does and how efficiently it does it.
The reader to whom this chapter is addressed is already familiar
with the general subject of electricity, but he may at any moment
desire to review or to supplement his general knowledge in
connection with some new appliance which, for the first time, applies
to commercial use one of the many and intricate laws of electrical
vibration. The whole subject of the nature and action of electricity is
outlined in the article Electricity (Vol. 9, p. 179), by Prof. J. A.
Fleming, of the University of London, one of the world’s foremost
authorities. In a space equivalent to hardly more than 30 pages of
this Guide, the field covered in detail by many other articles is so
concisely and clearly surveyed that you get a complete view of the
theoretical and practical developments by which electrical science
and industry have reached their present position. The same
contributor then considers Electrostatics (Vol. 9, p. 240) and
Electrokinetics (Vol. 9, p. 210); and, in Conduction, Electric
(Vol. 6, p. 855), deals with metallic, non-metallic, dielectric and
gaseous conductors. One section of this article is by Sir J. J.
Thomson, winner, in 1906, of the Nobel Prize for Physics. The form
in which metal is chiefly employed for the conduction of electricity is
the subject of a separate article, Wire (Vol. 28, p. 738); and the
articles on the individual metals deal with their electrical properties.
Batteries and The whole subject of the chemical
Dynamos production of electricity is discussed in
Electrolysis (Vol. 9, p. 217), by W. C.
D. Whetham, of the technical staff of Cambridge University. Battery
(Vol. 3, p. 531), fully illustrated, deals with all the forms of primary
battery, and Accumulator (Vol. 1, p. 126), also illustrated, by Walter
Hibbert, of the London Polytechnic, with all the secondary types. The
alkaline accumulators, of which the Edison apparatus is a well
known type, are the subject of a special section. Turning to
mechanically produced electricity, the first article to read is
Electromagnetism (Vol. 9, p. 226). This brings you naturally to the
article Dynamo (Vol. 8, p. 764), by C. C. Hawkins, author of one of
the best practical text-books on the subject. This copiously illustrated
article, in length equivalent to 50 pages of this Guide, discusses
continuous current dynamos, lap-winding, commutators, field-
magnets, forgings and castings for magnets, air-gaps, armature
cores, carbon brushes, cooling surfaces and alternators.
Having thus covered the subject of obtaining current, the group of
articles next to be considered is that dealing with its measurement
and the examination of resistances. The general article Units,
Physical (Vol. 27, p. 740), contains a section on electrical units.
Then come Potentiometer (Vol. 22, p. 205); Meter, Electric (Vol.
18, p. 291); Voltmeter (Vol. 28, p. 206), illustrated; Amperemeter
(Vol. 1, p. 879), illustrated; Ohmmeter (Vol. 20, p. 34); Wattmeter
(Vol. 28, p. 419); Galvanometer (Vol. 11, p. 428), illustrated;
Electrometer (Vol. 9, p. 234), illustrated; Electroscope (Vol. 9, p.
239), illustrated; Wheatstone’s Bridge (Vol. 28, p. 584), illustrated;
and Oscillograph (Vol. 20, p. 347), illustrated.
Lighting The commercial supply of current is
Appliances covered by a series of articles of which
the first to be read is Electricity
Supply (Vol. 9, p. 193), to which Emile Garcke, the famous electrical
engineer, contributes a section. Power Transmission, Electrical
(Vol. 22, p. 233), is by Louis Bell, chief engineer of the General
Electric Co., Boston; and contains full details as to the use of both
two-phase and three-phase generators in transmission. Induction
Coil (Vol. 14, p. 502) and Transformers (Vol. 27, p. 173) are both
fully illustrated. Lighting, Electric (Vol. 16, p. 659) deals with arc,
incandescent and vapour lamps, and with wiring. The section on
household work gives excellent practical information about the best
arrangements of lights. A special class of electric light supplies is
discussed in Lighthouse (Vol. 16, p. 627), by W. T. Douglass, who
erected the new Eddystone and the Bishop’s Rock lights, and by N.
G. Gedye, another practical expert.
The appliances used to convert current back again into the
mechanical energy from which it had been derived are described in
the article Motors, Electric (Vol. 18, p. 910). This article divides
continuous current motors into five classes: Separately excited;
series-wound constant current; series-wound constant potential;
series-wound interdependent current and potential; and shunt-
wound constant potential. Alternating current motors are similarly
classified as Synchronous constant potential; induction-polyphase
constant potential; induction monophase constant potential;
repulsion commutating, and series-commutating.
Trolley Cars and Machinery for applying electric
Railroads power to transportation, both for
trolley cars and heavy railroad traffic,
is described in the article Traction (Vol. 27, p. 118), by Prof. Louis
Duncan, who designed the first electric locomotives employed with
large loads—those introduced in 1895 by the Baltimore & Ohio R.R.
for its track in the tunnel under Baltimore. The article gives, with
many mechanical diagrams, accounts of the appliances by which the
current is taken from trolley wires, conduits and third rails, and of
the types of motors and controllers employed. Crane (Vol. 7, p. 368),
by Walter Pitt, describes the peculiar type of “crane-rated” motor, by
the aid of which steam and hydraulic cranes can be displaced. The
electric furnaces used for the reduction of ores and for
manufacturing processes in which exceptionally high temperatures
are required, are treated in Electrometallurgy (Vol. 9, p. 232), by
W. G. M’Millan, lecturer on metallurgy at Mason College,
Birmingham. Electric machinery for the refining of metals is dealt
with in the article Electrochemistry (Vol. 9, p. 208). Under
Surgical Instruments (Vol. 26, p. 133) there is a description of the
apparatus used for cautery and for illuminating parts of the interior
of the body. The appliances used in Electrotherapeutics are dealt
with under that heading (Vol. 9, p. 249). Information as to other
medical and surgical apparatus will be found under Röntgen Rays
(Vol. 23, p. 694), X-Ray Treatment (Vol. 28, p. 887), by Dr. H. L.
Jones, of St. Bartholomew’s Hospital, London; and Fluorescence
(Vol. 10, p. 575), by Prof. J. R. Cotter, of Trinity College, Dublin.
Telegraph and Telegraph (Vol. 26, p. 510),
Telephone equivalent in length to 70 pages of this
Guide, and fully illustrated, is by a
number of contributors, and discusses both land lines and
submarine cables. The section on instruments, by H. R. Kempe,
electrician to the General Post Office, London, includes a full
description of the transmitters and receivers employed in the various
systems of wireless telegraphy. Telephone (Vol. 26, p. 547) deals
with the fixed and portable instruments, the batteries and
switchboards, the new automatic exchange “selectors,” and with
special applications of the microphone.
A number of other electric appliances are discussed in separate
articles, such as Bell (Vol. 3, p. 692), by H. M. Ross, in which
burglar alarm devices are described; and Ventilation, Fan (Vol. 27,
p. 1011), by James Bartlett; while sparking plugs and other ignition
appliances are treated under Oil Engine (Vol. 20, p. 35).
There are also a number of appliances used mostly in experimental
and educational work. Such, for instance, are Electrical or
Electrostatic Machine (Vol. 9, p. 176), with many illustrations;
Electrophorus (Vol. 9, p. 237), and Leyden Jar (Vol. 16, p. 528).
The metals, chemicals and other materials sold by dealers in
electrical supplies, and their properties and uses, are described in
Copper (Vol. 7, p. 102), Zinc (Vol. 28, p. 981), Lead (Vol. 16, p. 314),
Sulphuric Acid (Vol. 26, p. 65), Sodium, Compounds (Vol. 25, p.
341); Chromium (Vol. 6, p. 296); Nitrogen, Compounds (Vol. 19, p.
715); Sal Ammoniac (Vol. 24, p. 59), Bichromates and Chromates
(Vol. 3, p. 912), Carbon (Vol. 5, p. 305), Rubber (Vol. 23, p. 795),
and Gutta Percha (Vol. 12, p. 743).
The following is a partial list, in alphabetical order, of articles of
peculiar interest to dealers in electrical supplies.

Accumulator
Amperemeter, or Ammeter
Armature
Battery
Bell
Bichromates and Chromates
Carbon
Chromium
Condenser
Conductor, Electric
Copper
Dielectric
Dynamo
Electricity
Electrical, or Electrostatic, Machine
Electricity Supply
Electrokinetics
Electrolysis
Electromagnetism
Electrometer
Electrophorus
Electroscope
Electrotherapeutics
Fluorescence
Fuze, or Fuse
Galvanometer
Gutta Percha
Induction Coil
Lead
Leyden Jar
Lighting
Meter, Electric
Motors, Electric
Nitrogen, Compounds
Ohmmeter
Oil Engine
Oscillograph
Potentiometer
Power Transmission
Röntgen Rays, Apparatus
Rubber
Sal Ammoniac
Sodium, Compounds
Sulphuric Acid
Surgical Instruments
Telegraph
Telephone
Thermometry, Electrical
Traction, Electric
Tramway
Transformers
Units, Physical
Vacuum Tube
Ventilation
Voltmeter
Wattmeter
Wheatstone’s Bridge
Wire
Zinc
CHAPTER XII
FOR MERCHANTS AND MANUFACTURERS
OF CHEMICALS AND DRUGS

A Factor in All The chemical and drug industry is not


Industries only in itself an enormous business,
but it supplies essential materials for
almost every branch of manufacturing. Chemical products are
employed in our buildings, our clothing, our food; we come into the
world and go out of the world with the odour of chemicals about us.
The manufacturer or dealer cannot analyze all the influences that
affect his market, and when he tries, as he must, to consider the
future of the trade, to reckon with the channels of demand that will
arise in the course of new applications of chemical products, he is
facing all the problems of all the industries.
The variety of raw materials from which chemical products are
derived, and the activity with which new sources are discovered and
developed, are almost as bewildering. Only a century has passed
since coal-tar was first distilled, and to-day no chemist would
venture to fix the limits of its industrial possibilities. Electrolysis has
been in use since 1804, and yet the future of the world’s wheat supply
probably depends upon processes, as yet hardly beyond the
experimental stage, of utilizing atmospheric nitrogen.
In connection with so comprehensive an industry, the uses of the
Britannica are so manifold that this whole Guide might be devoted to
them. Articles on every manufacturing process touch upon the use of
chemicals. The articles on countries, states and cities are full of
relevant information; and there is hardly a scientific article that
would not be helpful. But the 40 general articles on chemistry, the
350 on chemical compounds, and the 75 on manufactured products
call most immediately for attention; and, with the aid of other
chapters in the Guide, the reader who desires to go further will easily
find his way.
Articles on The article Chemistry (Vol. 6, p.
Chemicals 33), equivalent to 135 pages of this
Guide, is divided into 6 sections. The
first, History, traces the general trend of the science from its infancy
to the foundations of the modern theory. The second section,
Principles, treats of nomenclature, formulæ, chemical equations and
chemical changes. It provides a brief but complete introduction to
the terminology and methods of the chemist, and there is not a line
in it which will not prove of value in some way or other to the
chemical manufacturer. Sections 3 and 4 are devoted to Inorganic
and Organic Chemistry, giving a history of the subjects and the
principles underlying the structure of compounds, with cross
references to all articles dealing with their preparation and
properties. Sections 5 and 6 deal, respectively, with Analytical and
Physical Chemistry.
Dr. Walter Nernst, professor of physical chemistry, University of
Berlin, is the author of Chemical Action (Vol. 6, p. 26), which deals
specifically with the nature of chemical forces and deduces the laws
of chemical statics and kinetics. Of interest and importance in
connection with the manufacture of chemicals is Solution (Vol. 25,
p. 368), by W. C. D. Whetham, of Cambridge University, author of
Theory of Solution, etc. Another theoretical article which will be
found widely useful is Thermochemistry (Vol. 26, p. 804), by Prof.
James Walker, of Edinburgh University. For further details see the
chapter on Chemistry in this Guide.
Manufacture of It is possible here to mention only a
Chemicals small amount of the material dealing
with the manufacture of chemicals. At
the end of this chapter there is a fuller alphabetical list. It may be
noted, however, that the articles on the elements, metallic and non-
metallic, give much consideration to their compounds, how these are
made and how used in the arts and in medicine. But in addition to
this there are many noteworthy contributions dealing with chemical
manufacture. For instance, Alkali Manufacture (Vol. 1, p. 674), by
Dr. Georg Lunge, professor of technical chemistry, Zurich
Polytechnic, 11 pages in length and with 10 illustrations. The chief
processes described are the Leblanc, ammonia-soda, and electrolytic,
together with others dependent upon them. The facts about the
manufacture of the carbonate, hydrate, and sulphate of soda,
chlorine, hydrochloric acid, etc., are fully given. Potassium (Vol. 22,
p. 197) treats of the commercial compounds of this metal in the same
manner. Nitrogen (Vol. 19, p. 714) explains the new process for the
commercial manufacture of nitric acid from atmospheric air—a
matter of enormous industrial importance—and also the conversion
of nitrogen into ammonia, which has been done successfully only
within the past few years.
The manufacture of chemical products by the use of electricity is
the subject of Electrochemistry (Vol. 9, p. 208), and a still larger
field is covered by Electrometallurgy (Vol. 9, p. 232). Both of
these valuable articles are by W. G. M‘Millan, formerly secretary of
the Institute of Electrical Engineers of Great Britain. Sulphuric
Acid (Vol. 26, p. 65), illustrated, by Dr. Lunge, describes the
properties, reactions and manufacture of the most important of all
chemicals, including the more modern contact processes.
Drugs, Origin As a key to the subject of the origin
and Manufacture and manufacture of drugs, the article
Pharmacology (Vol. 21, p. 347), by
Dr. Ralph Stockman, professor of materia medica and therapeutics
in the University of Glasgow, presents a great amount of interesting
and valuable information on the action of chemical substances (apart
from foods) on all kinds of animals, from bacteria up to man. A short
history of pharmacology is given and a large part of the article
concerns the action of drugs. There is also a classification of drugs
according to the latest and most scientific methods into twenty-eight
groups, describing the effects of each group. An appendix to the
article, by Dr. H. L. Hennessy, is entitled Terminology in
Therapeutics, and is a general explanation of the common names
used in the therapeutic classification of drugs.
Since therapeutics is concerned with the remedial power of drugs
and the conditions under which they are to be used, the article
Therapeutics (Vol. 26, p. 793), by Dr. Sir Lauder Brunton, of St.
Bartholomew’s Hospital, London, and author of the well-known
treatise, Modern Therapeutics, should not be overlooked, nor
Poison (Vol. 21, p. 893), by Dr. Sir Thomas Stevenson, lecturer on
chemistry and forensic medicine at Guy’s Hospital, London, wherein
all poisons are classified and their antidotes are indicated.
Pharmacy (Vol. 21, p. 355), by E. M. Holmes, of the
Pharmaceutical Museum, London, is largely historical in its nature,
and yields much interesting and valuable information about the
pharmacist. We learn that an Egyptian papyrus of the date 2300 B.C.
gives direction as to the preparation of prescriptions, and that
diachylon plaster, invented by Menecrates in A.D. 1, is used for the
same purposes to-day. A great deal of curious knowledge about
ancient remedies, such as the thigh bone of a hanged man, moss
grown on a human skull, the ashes of the head of a coal-black cat,
etc., renders this article especially entertaining. Pharmacopœia (Vol.
21, p. 353), also by Mr. Holmes, tells about the pharmacopœias in
use in different countries, the standardization of drugs, etc.
In the list at the end of this chapter are noted the numerous
separate articles on drugs, their preparation and use that appear in
the Britannica. Mention should be made of the articles on the
elements, such as Iron (Vol. 14, p. 799), Arsenic (Vol. 2, p. 653),
Mercury (Vol. 18, p. 158), Iodine (Vol. 14, p. 725), Bromine (Vol. 4,
p. 633), Sodium (Vol. 25, p. 343), Potassium (Vol. 22, p. 200),
Magnesium (Vol. 17, p. 321), Bismuth (Vol. 4, p. 11). Separate
sections dealing with pharmacology are found in the articles on very
many plants, such as Aloe (Vol. 1, p. 720), Anise (Vol. 2, p. 55),
Arrowroot (Vol. 2, p. 649), Iceland Moss (Vol. 14, p. 241),
Cinchona (Vol. 6, p. 369), Coca (Vol. 6, p. 614), Colchicum (Vol. 6,
p. 661), Dandelion (Vol. 7, p. 801), Hop (Vol. 13, p. 678),
Horehound (Vol. 13, p. 692), Lobelia (Vol. 16, p. 837), Mint (Vol.
18, p. 557), Mustard (Vol. 19, p. 97), Peppermint (Vol. 21, p. 128),
etc.
Biographies of The scientific biographies include
Eminent not a few subjects which will be of
Scientists interest, owing to familiarity with the
names, to those engaged in the
chemical and drug business. Among these are Lister, Baron Joseph
L. (Vol. 16, p. 777), to whose work and teaching the present
importance of the manufacture of antiseptics is largely due; Pasteur,
Louis (Vol. 20, p. 892); Curie, Pierre, and Mme. Marie Curie (Vol.
7, p. 644), the physicists who first announced the existence of
radium; Liebig, Baron J. von (Vol. 16, p. 590), the great
physiological chemist; Lunge, Georg (Vol. 17, p. 126), the noted
expert in technical chemistry, already mentioned as a contributor to
the Britannica, and Glauber, J. R. (Vol. 12, p. 114), the German
chemist who made a living chiefly by the sale of secret chemical and
medicinal preparations.

ALPHABETICAL LIST OF ARTICLES IN THE


ENCYCLOPAEDIA BRITANNICA OF SPECIAL INTEREST
TO THOSE ENGAGED IN THE MANUFACTURE AND SALE
OF CHEMICALS AND DRUGS

Abel, Sir Frederick A.


Acacia
Acenaphthene
Acetic Acid
Aceto-Acetic Ester
Acetone
Acetophenone
Acetylene
Achard, F. C.
Acid
Acid Amides
Aconite
Acorus Calamus
Acridine
Adenine
Adipocere
Affinity, Chemical
Albumin, or Albumen
Alcohol
Alcohols
Aldehydes
Alembic
Algaroth, Powder of
Alizarin
Alkahest
Alkali
Alkali Manufacture
Alkaline Earths
Alkaloid
Alkanet
Allantoin
Alloxan
Alloxantin
Allyl Alcohol
Almond
Aloe
Alum
Aluminium
Amidines
Amines
Ammonia
Ammoniacum
Amygdalin
Amyl Alcohols
Amyl Nitrite
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like