100% found this document useful (1 vote)
69 views47 pages

JavaScript: Syntax and Practices 1st Edition Tomar PDF Download

The document is a promotional material for the book 'JavaScript: Syntax and Practices' by Ravi Tomar and Sarishma Dangi, published in 2022. It highlights the book's focus on JavaScript's capabilities in web development, covering both basic and advanced topics, and includes exercises and examples for practical learning. Additionally, it provides links to download the book and other related educational resources.

Uploaded by

ankelomelah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
69 views47 pages

JavaScript: Syntax and Practices 1st Edition Tomar PDF Download

The document is a promotional material for the book 'JavaScript: Syntax and Practices' by Ravi Tomar and Sarishma Dangi, published in 2022. It highlights the book's focus on JavaScript's capabilities in web development, covering both basic and advanced topics, and includes exercises and examples for practical learning. Additionally, it provides links to download the book and other related educational resources.

Uploaded by

ankelomelah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

JavaScript: Syntax and Practices 1st Edition

Tomar pdf download

https://ebookmeta.com/product/javascript-syntax-and-
practices-1st-edition-tomar/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

Primary Mathematics 3A Hoerst

https://ebookmeta.com/product/primary-mathematics-3a-hoerst/

Fog Computing Concepts Frameworks and Applications 1st


Edition Ravi Tomar

https://ebookmeta.com/product/fog-computing-concepts-frameworks-
and-applications-1st-edition-ravi-tomar/

Integration and Implementation of the Internet of


Things Through Cloud Computing 1st Edition Tomar

https://ebookmeta.com/product/integration-and-implementation-of-
the-internet-of-things-through-cloud-computing-1st-edition-tomar/

Essentials of CAS2 Assessment 1st Edition Jack A


Naglieri Tulio M Otero

https://ebookmeta.com/product/essentials-of-cas2-assessment-1st-
edition-jack-a-naglieri-tulio-m-otero/
Internet Security and You 1st Edition Sherri Mabry
Gordon

https://ebookmeta.com/product/internet-security-and-you-1st-
edition-sherri-mabry-gordon/

Emotions Ethics and Cinematic Experience New


Phenomenological and Cognitivist Perspectives 1st
Edition Robert Sinnerbrink

https://ebookmeta.com/product/emotions-ethics-and-cinematic-
experience-new-phenomenological-and-cognitivist-perspectives-1st-
edition-robert-sinnerbrink/

Human Centered Lean Six Sigma Creating a Culture of


Integrated Operational Excellence 1st Edition Hung Le

https://ebookmeta.com/product/human-centered-lean-six-sigma-
creating-a-culture-of-integrated-operational-excellence-1st-
edition-hung-le/

Football Entrepreneurship 1st Edition Vanessa Ratten

https://ebookmeta.com/product/football-entrepreneurship-1st-
edition-vanessa-ratten/

CRISC Review Questions Answers and Explanations 6th


Edition Isaca

https://ebookmeta.com/product/crisc-review-questions-answers-and-
explanations-6th-edition-isaca/
Interpersonal Positioning in English As a Lingua Franca
Interactions 1st Edition Svitlana Klötzl

https://ebookmeta.com/product/interpersonal-positioning-in-
english-as-a-lingua-franca-interactions-1st-edition-svitlana-
klotzl/
JavaScript
JavaScript
Syntax and Practices

Dr Ravi Tomar
Associate Professor, School of Computer Science,
University of Petroleum & Energy Studies,
Dehradun, India

Ms Sarishma Dangi
Assistant Professor, Graphic Era University,
Dehradun, India
First Edition published 2022
by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742
and by CRC Press
2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN
© 2022 selection and editorial matter, Ravi Tomar & Sarishma Dangi;
individual chapters, the contributors
CRC Press is an imprint of Taylor & Francis Group, LLC
Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot
assume responsibility for the validity of all materials or the consequences of their use. The authors and publishers
have attempted to trace the copyright holders of all material reproduced in this publication and apologize to
copyright holders if permission to publish in this form has not been obtained. If any copyright material has not
been acknowledged, please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted,
or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented,
including photocopying, microfilming, and recording, or in any information storage or retrieval system, without
written permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.com or contact
the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. For works
that are not available on CCC please contact [email protected]
Trademark notice: Product or corporate names may be trademarks or registered trademarks and are used only
for identification and explanation without intent to infringe.
Library of Congress Cataloging-in-Publication Data
Names: Tomar, Ravi, author. | Dangi, Sarishma, author. Title: JavaScript : syntax and practices / Ravi Tomar,
Sarishma Dangi.
Description: First edition. | Boca Raton : Chapman & Hall/CRC Press, 2022. | Includes bibliographical
references and index. | Summary: “Javascript is the most prominent web programming language in the
industry today and has endless capabilities in full stack web applications. JavaScript is most preferred because
of its compatibility with all the major browsers and its flexibility with the syntax it holds. Being a Front-end
language, JavaScript is also used on the server-side through Node.js. This book focuses on developing the basics
concepts of Javascript and enlightening the readers about the horizons that can be accessed using this language.
Offers detailed explanation of the core topics Covers both miscellaneous and advanced topics Gives a platform
to connect JavaScript to cutting edge technologies such as Cloud, Machine Learning, Internet of Things etc
Provides examples to enable ease of learning Includes exercises to get more comfortable with complex code Uses
case complete projects with examples This book is primarily aimed at undergraduates and graduates studying
web application development. Developers will also find it useful as a handbook”– Provided by publisher.
Identifiers: LCCN 2021032161 (print) | LCCN 2021032162 (ebook) | ISBN 9780367641429 (hardback) | ISBN
9780367641474 (paperback) | ISBN 9781003122364 (ebook) Subjects: LCSH: JavaScript (Computer program
language) | Object-oriented programming (Computer science) | Programming languages (Electronic
computers)--Syntax. | Web site development.
Classification: LCC QA76.73.J39 T64 2022 (print) | LCC QA76.73.J39 (ebook) | DDC 005.2/762–dc23
LC record available at https://lccn.loc.gov/2021032161
LC ebook record available at https://lccn.loc.gov/2021032162

ISBN: 978-0-367-64142-9 (hbk)


ISBN: 978-0-367-64147-4 (pbk)
ISBN: 978-1-003-12236-4 (ebk)
Access the companion website: https://www.routledge.com/9780367641429
DOI: 10.1201/9781003122364

Typeset in Palatino
by MPS Limited, Dehradun
To my loving parents, my wonderful partner Manu and my two little princesses

Kritika & Vedika. The continued support from my family and friends could make

this book possible.

- Ravi Tomar

To my parents, Rajender and Sushila.

I am grateful for your nurturing and contribution which bought me here. I promise

you that I will never give up and continue to strive with my brightest light. I will

leave a trace in this world, one with your names behind it. Thank you for all the

love, light, support, warmth and especially the wings you gave me to fly.

- Sarishma Dangi
Contents

Preface.....................................................................................................................xv
Acknowledgements ........................................................................................... xvii
Authors..................................................................................................................xix

1. Introduction.....................................................................................................1
1.1 Introduction to Web Development................................................... 1
1.2 Client-Side and Server-Side JavaScript ............................................ 3
1.3 Origin, History and Evolution of JavaScript .................................. 4
1.4 Features of JavaScript.......................................................................... 6
1.5 Advantages and Limitations.............................................................. 8
1.6 Structure of Browsers........................................................................ 10
1.7 Saying Hello World to JS.................................................................... 11
1.7.1 Built-In Functions................................................................. 12
1.7.2 Gathering Software .............................................................. 13
1.7.2.1 Examples of Framework, Library and
Tools ........................................................................14
1.8 Placement of Code............................................................................. 15
1.9 Exercise ................................................................................................ 17
1.9.1 Theory .................................................................................... 17
1.9.2 True/False ............................................................................. 17
1.9.3 Multiple-Choice Questions ................................................. 18

2. Building the Basics......................................................................................19


2.1 Lexical Structure ................................................................................ 19
2.2 Character Set....................................................................................... 19
2.2.1 Whitespace and Comments................................................ 20
2.2.2 Case Sensitivity..................................................................... 20
2.2.3 Semicolons ............................................................................. 20
2.2.4 Literals.................................................................................... 21
2.2.5 Identifiers ............................................................................... 21
2.2.6 Keywords............................................................................... 21
2.3 Variables .............................................................................................. 22
2.3.1 Variable Declaration and Scope......................................... 22
2.4 Data Types .......................................................................................... 24
2.4.1 Primitive Data Types........................................................... 25
2.4.2 Nonprimitive Data Types ................................................... 27
2.4.3 Constants ............................................................................... 27
2.4.4 Type Casting ......................................................................... 28
2.5 Operators ............................................................................................. 29
2.5.1 Arithmetic Operators......................................................... 29

vii
viii Contents

2.5.2 Comparison Operators ...................................................... 29


2.5.3 Bitwise Operators ............................................................... 31
2.5.4 Logical Operators ............................................................... 31
2.5.5 Assignment Operator ........................................................ 31
2.5.6 Ternary Operator................................................................ 32
2.5.7 Comma Operator................................................................ 33
2.5.8 Typeof Operator ................................................................. 33
2.5.9 Delete Operator .................................................................. 34
2.5.10 Void Operator ..................................................................... 34
2.6 Control Flow Statements .................................................................. 34
2.6.1 Decision Statements ............................................................. 34
2.6.1.1 If Else ......................................................................35
2.6.1.2 Switch Case Statement.........................................36
2.6.2 Loops and Iterations ............................................................ 37
2.6.2.1 For Loop ................................................................. 37
2.6.2.2 While Loop.............................................................38
2.6.2.3 Do-While Loop ...................................................... 38
2.6.2.4 For-In Loop ............................................................39
2.7 Exercise ................................................................................................ 39
2.7.1 Theory .................................................................................... 39
2.7.2 True/False ............................................................................. 40
2.7.3 Multiple-Choice Questions ................................................. 40
2.8 Demo and Hands-On for Variables and
Assignment Operator ........................................................................ 41
2.8.1 Objective ................................................................................ 41
2.8.2 Prerequisite............................................................................ 41
2.8.3 Explore ................................................................................... 42
2.8.3.1 Code Snippet-1 ...................................................... 42
2.8.3.2 Code Snippet-2 ...................................................... 42
2.8.3.3 Code Snippet-3 ...................................................... 43
2.9 Demo and Hands-On for Control Flow
Statements ........................................................................................... 43
2.9.1 Objective ................................................................................ 43
2.9.2 Prerequisite............................................................................ 44
2.9.3 Explore ................................................................................... 44
2.9.3.1 Code Snippet-1 ...................................................... 44
2.9.3.2 Code Snippet-2 ...................................................... 45

3. Objects............................................................................................................47
3.1 Objects.................................................................................................. 48
3.2 Properties of Objects ......................................................................... 50
3.2.1 Property Configuration Descriptors ................................. 50
3.3 Creating Objects................................................................................. 52
3.4 Objects as Record and Dictionary .................................................. 54
3.5 Operations on Objects....................................................................... 55
Contents ix

3.5.1 Accessors and Mutators...................................................... 55


3.5.2 Useful Operations and Loops............................................ 57
3.5.3 Object Methods..................................................................... 60
3.5.4 Built-In Object Methods...................................................... 61
3.6 Prototypal Inheritance ...................................................................... 63
3.6.1 Prototype Chaining.............................................................. 64
3.7 Classes ................................................................................................. 65
3.7.1 Constructor, Properties and Methods .............................. 66
3.7.2 Extending Classes ................................................................ 68
3.7.3 Getters and Setters in Classes............................................ 69
3.7.4 Static Members ..................................................................... 70
3.8 Garbage Collection ............................................................................ 71
3.9 Exercise ................................................................................................ 73
3.9.1 Theory .................................................................................... 73
3.9.2 True/False ............................................................................. 73
3.9.3 Multiple-Choice Questions................................................. 74
3.10 Demo and Hands-On for Objects ................................................... 75
3.10.1 Objective .............................................................................. 75
3.10.2 Prerequisite.......................................................................... 75
3.10.3 Explore ................................................................................. 75
3.10.3.1 Code Snippet-1..................................................76
3.10.3.2 Code Snippet-2..................................................77
3.10.3.3 Code Snippet-3..................................................78

4. Functions........................................................................................................ 81
4.1 Functions in JavaScript ..................................................................... 81
4.2 Function Variable Scope ................................................................... 82
4.3 Function Declaration ......................................................................... 84
4.3.1 Traditional Function Declaration ...................................... 85
4.3.2 Function Expressions........................................................... 85
4.3.3 Arrow Function Expressions.............................................. 86
4.3.3.1 Limitations of Arrow Functions.........................87
4.4 Parameters in a Function.................................................................. 89
4.4.1 Return Keyword in Functions ........................................... 89
4.4.2 Invoking a Function............................................................. 89
4.4.3 Recursion ............................................................................... 90
4.4.4 Closures.................................................................................. 90
4.5 Exercise ................................................................................................ 91
4.5.1 Theory .................................................................................... 91
4.5.2 True/False ............................................................................. 91
4.5.3 Multiple-Choice Questions ................................................. 92
4.6 Demo and Hands-On for Functions............................................... 93
4.6.1 Objective ................................................................................ 93
4.6.2 Prerequisite............................................................................ 93
x Contents

4.6.3 Explore ................................................................................... 93


4.6.3.1 Code Snippet-1 ...................................................... 94
4.6.3.2 Code Snippet-2 ...................................................... 96

5. Arrays .............................................................................................................99
5.1 Array .................................................................................................... 99
5.2 Properties of Array.......................................................................... 100
5.3 Declaring an Array.......................................................................... 100
5.3.1 Array Literal........................................................................ 101
5.3.2 Using the New Keyword and Array Constructor ....... 101
5.4 Accessing an Array ......................................................................... 102
5.5 Built-In Methods inside Array ...................................................... 103
5.5.1 Accessor Methods .............................................................. 103
5.5.2 Mutator Methods ............................................................... 107
5.5.3 Iterator Methods................................................................. 111
5.5.3.1 Using Fundamental Loops................................ 112
5.5.3.2 Predefined Iterator Methods.............................112
5.6 Nesting and Multidimensional Arrays........................................ 116
5.7 Sorting................................................................................................ 117
5.8 Points to Ponder .............................................................................. 119
5.9 Exercise .............................................................................................. 120
5.9.1 Theory .................................................................................. 120
5.9.2 True/False ........................................................................... 120
5.9.3 Multiple-Choice Questions............................................... 120
5.10 Demo and Hands-On for Arrays.................................................. 122
5.10.1 Objective............................................................................ 122
5.10.2 Prerequisite........................................................................ 122
5.10.3 Explore ............................................................................... 122
5.10.3.1 Code Snippet-1 ...............................................122
5.10.3.2 Code Snippet-2................................................123
5.10.3.3 Code Snippet-3................................................125

6. Browser Object Model..............................................................................127


6.1 Browser Object Model..................................................................... 127
6.2 Window Object................................................................................. 129
6.2.1 Properties of Window Object........................................... 131
6.2.2 Methods of Window Object ............................................. 132
6.3 History Object................................................................................... 134
6.3.1 Properties of History Object............................................. 135
6.3.2 Methods of History Object ............................................... 135
6.4 Navigator Object .............................................................................. 136
6.4.1 Properties and Methods of Navigator
Object.................................................................................... 137
6.5 Location Object................................................................................. 138
6.5.1 Properties of Location Object........................................... 138
Contents xi

6.5.2 Methods of Location Object ............................................. 139


6.6 Screen Object .................................................................................... 139
6.6.1 Properties of Screen Object............................................... 139
6.7 Document Object.............................................................................. 140
6.8 Exercise .............................................................................................. 140
6.8.1 Theory .................................................................................. 140
6.8.2 True/False ........................................................................... 140
6.8.3 Multiple-Choice Questions ............................................... 141
6.9 Demo and Hands-On for BOM..................................................... 142
6.9.1 Objective .............................................................................. 142
6.9.2 Prerequisites ........................................................................ 142
6.9.3 Explore ................................................................................. 142
6.9.3.1 Code Snippet-1 .................................................... 142
6.9.3.2 Code Snippet-2 .................................................... 143

7. Document Object Model.......................................................................... 145


7.1 Document Object Model (DOM) .................................................. 145
7.2 Relationship between BOM, DOM and
JavaScript .......................................................................................... 148
7.3 Understanding DOM Tree and Nodes ........................................ 151
7.3.1 Properties of Node Object ................................................ 153
7.3.2 Method of Node Object .................................................... 154
7.4 Document Object ............................................................................. 155
7.4.1 Properties of Document Object ....................................... 155
7.4.2 Methods for Document Object ........................................ 156
7.5 Elements in DOM ............................................................................ 157
7.5.1 Properties of Element Object ........................................... 157
7.5.2 Methods for Element Object ............................................ 158
7.6 Accessing Elements in the DOM .................................................. 159
7.7 Event Handling Using DOM......................................................... 162
7.8 Exercise .............................................................................................. 164
7.8.1 Theory .................................................................................. 164
7.8.2 True/False ........................................................................... 164
7.8.3 Multiple-Choice Questions............................................... 164
7.9 Demo and Hands-On DOM .......................................................... 165
7.9.1 Objective .............................................................................. 165
7.9.2 Prerequisite.......................................................................... 165
7.9.3 Explore ................................................................................. 166
7.9.3.1 Code Snippet-1.................................................... 166
7.9.3.2 Code Snippet-2.................................................... 167
7.9.3.3 Code Snippet-3.................................................... 169
7.9.3.4 Code Snippet-4.................................................... 170
7.10 Demo and Hands-On for Event Delegation ............................... 174
7.10.1 Objective ............................................................................ 174
7.10.2 Prerequisite........................................................................ 174
xii Contents

7.10.3 Explore ............................................................................... 175


7.10.3.1 Code Snippet-1................................................175
7.10.3.2 Code Snippet-2................................................177

8. Standard Built-In Objects ........................................................................ 179


8.1 Built-In Objects................................................................................. 179
8.1.1 Fundamental Objects ......................................................... 180
8.1.1.1 Object Prototype..................................................180
8.1.1.2 Function Object ................................................... 181
8.1.1.3 Boolean Object..................................................... 181
8.1.1.4 Symbol Object...................................................... 183
8.1.2 Error Objects ....................................................................... 184
8.1.3 Number and Dates............................................................. 184
8.1.3.1 Number Object .................................................... 184
8.1.3.2 Date Object...........................................................186
8.1.3.3 Math Object..........................................................188
8.1.4 Text or String Processing .................................................. 190
8.1.4.1 String Object ........................................................190
8.1.4.2 RegExp Object ..................................................... 193
8.1.5 Keyed Collections............................................................... 195
8.1.5.1 Map Object...........................................................195
8.1.5.2 Set Object.............................................................. 196
8.1.6 Indexed Collections............................................................ 197
8.1.6.1 Array Object.........................................................197
8.1.7 Structured Data................................................................... 199
8.1.8 Value Properties ................................................................. 199
8.1.9 Function Properties............................................................ 200
8.2 Exercise .............................................................................................. 201
8.2.1 Theory .................................................................................. 201
8.2.2 True/False ........................................................................... 202
8.2.3 Multiple-Choice Questions ............................................... 202
8.3 Demo and Hands-On for Loops ................................................... 203
8.3.1 Objective .............................................................................. 203
8.3.2 Prerequisite.......................................................................... 203
8.3.3 Explore ................................................................................. 203
8.3.3.1 Code Snippet-1 .................................................... 203
8.3.3.2 Code Snippet-2 .................................................... 204
8.3.3.3 Code Snippet-3 .................................................... 205
8.4 Demo and Hands-On for Hoisting............................................... 207
8.4.1 Objective .............................................................................. 207
8.4.2 Prerequisite.......................................................................... 207
8.4.3 Explore ................................................................................. 207
8.4.3.1 Code Snippet-1 .................................................... 208
8.4.3.2 Code Snippet-2 .................................................... 209
Contents xiii

9. Validation, Error Handling and Cookies .............................................211


9.1 Validation .......................................................................................... 211
9.1.1 Server- and Client-Side Validation ................................. 212
9.1.2 Using Built-In Form Validation ....................................... 212
9.1.3 Using JavaScript for Validation ....................................... 214
9.2 Error Handling ................................................................................. 215
9.2.1 Error Object ......................................................................... 216
9.2.2 Try-Catch Block .................................................................. 217
9.2.3 Finally Block........................................................................ 218
9.2.4 Throw Statement ................................................................ 219
9.3 Cookies .............................................................................................. 219
9.4 Strict Mode........................................................................................ 220
9.5 Best Practices .................................................................................... 222
9.6 Exercise .............................................................................................. 224
9.6.1 Theory .................................................................................. 224
9.6.2 True/False ........................................................................... 225
9.6.3 Multiple-Choice Questions ............................................... 225
9.7 Demo and Hands-On for Form Validation and Cookies. ........ 226
9.7.1 Objective .............................................................................. 226
9.7.2 Prerequisite.......................................................................... 226
9.7.3 Explore ................................................................................. 226
9.7.3.1 Code Snippet-1 .................................................... 226

10. Miscellaneous Case Studies ....................................................................229


10.1 Case Study-1: Introduction to Fetch API................................... 229
10.1.1 Objective .......................................................................... 229
10.1.2 Prerequisite...................................................................... 229
10.1.3 Explore ............................................................................. 230
10.1.3.1 Code Snippet-1 ..............................................230
10.2 Case Study-2: Integrating MongoDB in Cloud ........................ 231
10.2.1 Objective .......................................................................... 231
10.2.2 Prerequisite...................................................................... 231
10.2.2.1 MongoDB Cloud Connection ..................... 231
10.2.2.2 Docker Container for Node.js..................... 232
10.2.3 Agenda ............................................................................. 233
10.2.4 Explore ............................................................................. 233
10.2.4.1 Front-End Script for Invoking Our
Custom APIs..................................................233
10.2.4.2 Code Walkthrough .......................................234
10.2.4.3 Creating Node.js Backend ...........................234
10.3 Case Study-3: Visualizing Graphs with
JavaScript......................................................................................... 237
10.3.1 Objective .......................................................................... 237
10.3.2 Prerequisite...................................................................... 237
10.3.3 Agenda ............................................................................. 237
xiv Contents

10.3.4 Explore ............................................................................. 237


10.3.5 Front-End Script for Invoking Our
Custom APIs ................................................................... 237
10.4 Case Study-4: Integrating Firebase Auth................................... 239
10.4.1 Objective .......................................................................... 239
10.4.2 Background ..................................................................... 239
10.4.3 Prerequisite...................................................................... 239
10.4.4 Agenda ............................................................................. 240
10.4.5 Explore ............................................................................. 240
10.4.5.1 Creating a Login Page ................................. 240
10.4.5.2 Code Walkthrough .......................................241
10.4.5.3 Creating Home Page ....................................242
10.4.5.4 Code Walkthrough .......................................243
References............................................................................................................ 245
Index .....................................................................................................................253
Other documents randomly have
different content
The Project Gutenberg eBook of Custis-Lee
Mansion: The Robert E. Lee Memorial, Virginia
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Custis-Lee Mansion: The Robert E. Lee Memorial, Virginia

Author: Murray H. Nelligan

Release date: November 29, 2015 [eBook #50570]


Most recently updated: October 22, 2024

Language: English

Credits: Produced by Stephen Hutcheson, Dave Morgan and the


Online
Distributed Proofreading Team at http://www.pgdp.net

*** START OF THE PROJECT GUTENBERG EBOOK CUSTIS-LEE


MANSION: THE ROBERT E. LEE MEMORIAL, VIRGINIA ***
UNITED STATES DEPARTMENT OF THE INTERIOR
Stewart L. Udall, Secretary

NATIONAL PARK SERVICE


Conrad L. Wirth, Director

HISTORICAL HANDBOOK NUMBER SIX

This publication is one of a series of handbooks describing the


historical and archeological areas in the National Park System
administered by the National Park Service of the United States
Department of the Interior. It is printed by the Government Printing
Office and may be purchased from the Superintendent of Documents,
Washington 25, D. C. Price 25 cents.
CUSTIS-LEE MANSION
The Robert E. Lee Memorial
VIRGINIA
by Murray H. Nelligan

NATIONAL PARK SERVICE HISTORICAL HANDBOOK SERIES No. 6


WASHINGTON, D.C., 1950 (REVISED 1962)
The National Park System, of which Custis-Lee Mansion is a
unit, is dedicated to conserving the scenic, scientific, and
historic heritage of the United States for the benefit and
enjoyment of its people.
Contents
Page
History of Arlington to 1861 1
Arlington from 1861 to 1865 24
Arlington from 1865 to the Present 26
Guide to the House and Grounds 28
Visitor Service and Facilities 46
Administration 47
Suggested Readings 48
General Robert E. Lee in 1865. From the original photograph by
Mathew Brady in the National Archives.
1

Ever since it was built more than a century ago, the Custis-Lee
Mansion has dominated the scene across the river from the National
Capital. An outstanding example of a Greek Revival building of the
early nineteenth century, its dignity and strength, simplicity and
steady grace, now make it a most appropriate national memorial to
one of America’s greatest men, Robert E. Lee.

Built by his father-in-law, George Washington Parke Custis, the


adopted son of General Washington, the mansion was for many years
a principal repository of many objects associated with George
Washington. As such, it greatly influenced Robert E. Lee when the
building was his home. Like him, it experienced the vicissitudes of
war and came to be associated with his fame. Now it is maintained
by the Nation in his honor, and in the years to come will serve as a
constant reminder of his nobility and greatness.

Many years have passed since General Lee lived in the home at
Arlington. But so real are the memories evoked by its historic
atmosphere, it seems little more than yesterday that he left it for the
last time. A visit to the Custis-Lee Mansion gives a deeper, more
personal understanding of the life and worth of the man to whose
memory it is now dedicated.
History of Arlington to 1861

ANCESTRY OF GEORGE WASHINGTON PARKE CUSTIS. George Washington


Parke Custis was born April 30, 1781. His mother was Eleanor
(Calvert) Custis, a granddaughter of the sixth Lord Baltimore; his
father, John Parke Custis, the only son of Martha Washington by her
first marriage. John Parke Custis grew to manhood at Mount Vernon,
married Eleanor Calvert in 1774, and died of camp fever in 1781
while serving as aide to General Washington at Yorktown. His death
left four children fatherless, so the two youngest, George Washington
Parke Custis and his sister Eleanor, were adopted by the Washingtons
and taken to Mount Vernon to be raised as their own.

2
HIS EARLY LIFE AT MOUNT VERNON. Only 6 months old when he was
taken to live at Mount Vernon, it was a remarkable experience for a
boy as sensitive and gifted as young Custis to grow up on terms of
intimacy with General Washington, whose affection the fatherless lad
reciprocated with the deepest love and respect. As far as public
duties would allow, the General supervised the training and education
of the boy, who acquired from him the interests and ideals which
established the pattern of his life. “It is really an enjoyment to be
here to witness the tranquil happiness that reigns throughout the
house,” wrote a guest at Mount Vernon in 1799, “except when now
and then a little bustle is occasioned by the young Squire Custis when
he returns from hunting, bringing in a ‘valiant deer’, as he terms it,
that Grandpa and the Colonel will devour: nice venison I assure you.”

GEORGE WASHINGTON PARKE CUSTIS MOVES TO ARLINGTON. Custis was 18


when the General died in 1799. Mrs. Washington did not long survive
her husband, and when she died, early in 1802, Custis moved to
“Mount Washington,” as he first called the Arlington estate. This was
a tract of nearly 1,100 acres that Custis’ father had bought in 1778
with the intention of establishing a family seat convenient to Mount
Vernon, but in 1802 the only tangible remains of his brief ownership
were the flourishing willows he had planted along the Potomac.

“ARLINGTON HOUSE” BEGUN. When Custis moved into a cottage built by


the former owners of the property, Arlington consisted mostly of
woodland and virgin oak forests, with a few cleared fields near the
river. His first concern was to get the fields under cultivation, using
for the purpose the mules and farm equipment he had purchased at
the sales held that year at Mount Vernon to settle the legacies of the
several Washington heirs. Equally urgent was the need to build a
house worthy of the furnishings and mementoes which he had
inherited or bought at the Mount Vernon sales, some of which were
deteriorating badly in their temporary quarters. To this end, he seems
to have obtained building plans from George Hadfield, a gifted young
architect, who had come from England in 1795 to take charge of the
construction of the Capitol.

Influenced by the contemporary vogue for classical architecture,


Custis wanted his house to be in the new style, and the architect’s
finished design was a simplified Greek Doric portico balanced by
extended wings, the whole of such sturdiness as to show to
advantage when viewed from across the river. Since ornamentation
would be lost at such a distance, the architect largely dispensed with
it, relying on good proportions to give beauty to his creation. Rooms
would be large and have high ceilings and tall windows, and their
severely plain walls would be perfect for displaying the many portraits
Custis possessed. Having the rooms open into each other would give
extensive vistas, framed by pleasing semicircular arches.

3
Early view of Mount Vernon.
George Washington Parke Custis. From a miniature made at
Mount Vernon in 1799.
Though clay for bricks and choice timber were at hand on his estate,
Custis lacked the money necessary to build his house all at once.
Therefore he followed the common practice of building the wings
first, and the main section later. The north wing was built about
1803, and was evidently intended to be one great banquet room. By
1804, the south wing was completed, containing an office and a large
room for entertaining. In that year Custis married Mary Lee Fitzhugh.
To provide living quarters for himself and his bride he had the north
wing partitioned into three small rooms. With a kitchen and laundry
in the basement, the young couple had the essentials of living at
“Arlington House,” as Custis named his new home, after the old
family seat on the Eastern Shore. At this point, work seems to have
been stopped. A visitor reported in 1811, “I was struck, on entering
the grounds of Mr. Custis, at Arlington, ... with several of the most
picturesque views. This seat is on a superb mount, and his buildings
are begun in a stile of superior taste and elegance.”

ARLINGTON AND THE DEVELOPMENT OF AMERICAN AGRICULTURE. While


building his house, Custis inaugurated an annual fair designed to
improve agricultural practices in general, and particularly the
breeding of fine-wooled sheep. Beginning in 1803, Custis invited the
local gentry each spring to exhibit their best sheep and homespun
cloth at Arlington Spring, near the edge of the river. After prizes had
been awarded, the fair would close with patriotic speeches and a
great dinner under the tent which had been used by Washington
during the Revolution.

“ARLINGTON HOUSE,” AS IT APPEARED FROM ABOUT 1804-1816


By breeding the native stock on his farms with the imported stock he
had acquired from Mount Vernon, Custis himself developed a hardy
race of fine-wooled sheep, known as the “Arlington Improved.”
Because the wool of this breed could be woven into finer cloth than
hitherto possible, the Arlington sheep were widely diffused
throughout the country. Custis also sought to correct the primitive
agricultural methods which had already caused much land in his State
to be abandoned because of soil erosion. He advocated the
establishment of a National Board of Agriculture with functions like
those of the Department of Agriculture today, and he offered one of
his outlying properties for use as an experimental breeding station.
So popular was the Arlington Sheepshearing, as it was commonly
called, that the idea was quickly adopted elsewhere. Though
economic conditions forced Custis to discontinue the event after
1812, it was one of the primary sources of the great program of
agricultural improvement in effect today.

BIRTH OF MARY ANNA RANDOLPH CUSTIS. Mary Anna Randolph Custis,


born in 1808, was the only one of the four Custis children to survive
the first year of infancy. Upon her the parents centered their
affections and hopes. The mother’s natural piety and devotion to her
family were deepened by the loss of her other children, while the
father’s warm and generous nature was such that in later years she
could not recall ever having received an unkind word from him.

CUSTIS AND THE WAR OF 1812. During the War of 1812, the British
blockade of the Chesapeake deprived Custis of much of the income
from his other estates, so it is doubtful if any building was done at
Arlington at this time. Convinced that Napoleon threatened the
liberties of mankind more than England, Custis strongly opposed the
war. For this reason he was chosen to deliver the funeral oration for
General Lingan, a veteran of the Revolution who was murdered by
the same Baltimore mob which almost killed Robert E. Lee’s father,
“Light-Horse Harry” Lee. Nevertheless, Custis followed the example
set by George Washington during the American Revolution by
forbidding the managers of his plantations to furnish supplies to the
British; and when British troops approached the National Capital in
1814, Custis fought in the ranks at the battle of Bladensburg.

Arlington Spring, scene of the famous “Sheepshearings.”

“ARLINGTON HOUSE” COMPLETED. After the war, Custis resumed work on


his house, and the large center section and great portico were to
have been finished in 1817. “A house that any one might see with
half an eye,” as Robert E. Lee later described it, could not fail to
attract attention, and “Custis’ Folly” is first mentioned by a traveler in
1818. Although the interior was never completed as planned and the
rear was left unstuccoed, “Arlington House” was soon considered one
of the handsomest residences about Washington. One early writer
describes it as “a noble-looking place, having a portico of stately
white columns, which, as the mansion stands high, with a back
ground of dark woods, forms a beautiful object in the landscape.”

THE MEMORY OF GEORGE WASHINGTON KEPT ALIVE AT ARLINGTON. “Arlington


House” now became the successor of Mount Vernon as the
“Washington Treasury,” as Custis termed it. His collection of
Washington relics was the largest in existence, and it filled the 6
halls and rooms of the mansion. The owner of these relics
welcomed all who wished to view them, and he never tired of
entertaining his guests with tales of his early years at Mount Vernon.
Many distinguished men visited Arlington at one time or other—Sam
Houston, Daniel Webster, and Andrew Jackson, to name a few. One
of the most notable was General Lafayette, who twice was a guest
there when he toured the United States in 1824 and 1825. Custis
spent much time with the venerable marquis, and used the wealth of
reminiscenses he gained from the old soldier to write the delightful
Conversations With Lafayette, which was published in a local
newspaper in 1825. Encouraged by their favorable reception, he then
began his own Recollections and Private Memoirs of Washington,
which proved equally popular and were widely reprinted in the
newspapers of the period.

Even more successful were the dramas Custis wrote at this time,
based on heroic episodes in the Nation’s past or on inspiring
contemporary achievements. The Indian Prophecy used an incident in
Washington’s early life as its theme and established a vogue for
Indian plays which lasted over 50 years; while the Rail Road was the
first one written on that subject in America. Others dramatized such
events as the battle of Baltimore and the launching of a new warship.
For 10 years his dramatic pieces were staged from Boston to
Charleston and did much to develop a distinctive American drama.
An early view of “Arlington House.” From an engraving made
about 1845.

A man of culture, Custis used all of his abilities to perpetuate the


memory of Washington. He erected the first monument on the
President’s birthplace in 1816, wrote poems to celebrate his 7
greatness, and painted colorful battle pictures in which the great
General was the central figure. An accomplished orator, he was
tireless in advocating the principles of freedom for which Washington
had fought, and planned to do with his slaves as his foster father had
done—free them after they had been prepared to shift for
themselves. Although he never held an elective office, his influence
was considerable and for the good.
The tents used by General Washington during the American
Revolution were cherished relics at Arlington. From B. J.
Lossing, “Arlington House,” Harper’s Monthly Magazine, VII
(Sept. 1853), 444.

HOME LIFE AT ARLINGTON. An equal source of inspiration at “Arlington


House” was the religious atmosphere of its home life. Mrs. Custis was
a devout Episcopalian, noted for her simplicity and piety. It was she
who influenced Robert E. Lee’s Sunday school teacher, Bishop William
Meade, to enter the ministry. Diligent where her husband was
inclined to be easy-going, Mrs. Custis was one with him in making
Arlington free from ostentation.

Kept unspoiled by her parents’ example, Mary Custis was given the
education deemed necessary for a young lady of her position, and as
soon as she was old enough herself taught the children of nearby
families and family servants. Though an only child, she never lacked
companionship, for usually the house overflowed with relatives and
their children. The Custises, too, often went visiting, especially to
“Ravensworth,” formerly the home of Mrs. Custis’ father and now
owned by her only brother. Here Mary must have played as a child
with Robert E. Lee, for he and his mother were also related to the
Fitzhughs and often visited at their estate. The Lees were familiar
with Arlington as well, for Robert was a favorite with the Custises
from boyhood. He and Mary Custis are said to have planted some of
the trees in the vicinity of the house when they were young.

8
Title page of the 1830 edition of Curtis’ most popular play.
POCAHONTAS!
OR,
THE SETTLERS OF VIRGINIA,

A NATIONAL DRAMA,
IN THREE ACTS.

Performed at the Walnut Street Theatre, Philadelphia, twelve nights, with


great success.

WRITTEN BY
GEORGE WASHINGTON CUSTIS, ESQ.
Of Arlington House. Author of the Rail Road, Pawnee Chief, &c. &c.

PHILADELPHIA EDITION.
© ALEXANDER, PR.
:::::::
1830.

MARRIAGE OF MARY CUSTIS AND ROBERT E. LEE. Childhood friendship 9


turned to love by the time Lee graduated from West Point and
was assigned to duty in the Corps of Engineers. Whenever possible
he was at Arlington courting Mary Custis, and in the summer of 1830
they became engaged.

The evening of the wedding, June 30, 1831, was one of steady rain,
but nothing could affect the warmth and happiness inside the friendly
portals of Arlington. The ceremony was formal and elaborate as
befitted the union of two of the most prominent families of Virginia.
The happy couple, surrounded by pretty bridesmaids and uniformed
groomsmen, made a picturesque scene.

George Washington Parke Custis. Engraved from the portrait


by Gilbert Stuart made about 1825.

THE LEES AT FORT MONROE, 1831 TO 1834. Wedding trips not being
customary at that time, the young married couple stayed at Arlington
until it was time for them to go to Fort Monroe where Lee was
stationed. At Christmas they returned home, and, because of the bad
weather, Mrs. Lee remained there till spring. Furniture and choice
provisions from the Custis farms helped to make the Lee’s quarters at
the fort more homelike, while Mrs. Custis’ frequent letters 10
lessened her daughter’s homesickness, as did the whimsical,
chatty ones her father wrote regularly to his “Dr Son & Daughter.” In
September of 1832, their first child was born there, a son named
George Washington Custis Lee, after his grandfather. Christmas that
year at Arlington was especially happy because of the new baby
(known familiarly as “Custis” Lee), and because Lee was
unexpectedly able to be there. The following year passed much the
same way.

Lieutenant and Mrs. Robert E. Lee in 1838. From the portraits


by William E. West. U. S. Army Signal Corps photographs.

In the autumn of 1834, Lee


LEE ON DUTY AT WASHINGTON, 1834 TO 1837.
was transferred to Washington and with his family made his home at
Arlington. Sometimes his work kept him away overnight, but usually
each morning and afternoon he was to be seen riding between his
office and home. Lee disliked the office work which kept him in the
city until the middle of 1837, but life at Arlington was most pleasant.
Mrs. Lee’s parents idolized their little grandson, and for them Lee felt
a growing respect and affection. Custis was the nearest link to the
first President, and associating with him and living in the presence of
so many of the General’s personal belongings made Washington very
close and real to the young engineer, an example and influence that
steadily entered his soul.

Lee fitted easily into the quiet way of life at Arlington. Mrs. Lee and
her mother cared little for formal social affairs, preferring to be out of
doors gardening or riding about the estate when not 11
entertaining visitors. Mr. Custis was usually busy with his farm,
and since he liked to hunt, he might often be seen walking or riding
about the estate with his gun and dogs; evenings he spent with his
family by the hearth, or retired to his study to work on his literary
efforts. Each morning and evening the family and servants gathered
for prayers, and grace was said before each meal. On Sundays the
family usually drove into Alexandria to church, or held services at
home if the roads were bad. Mrs. Lee, like her father, was an
amateur artist, an interest shared by her husband who also
occasionally assisted Mr. Custis in his business affairs or put his
engineering experience to use in making improvements.

Troubles there were, of course. Lee was away on a mission to Ohio


and Michigan when his second child, a daughter whom they named
Mary, was born in the summer of 1835. When he returned, he found
his wife so seriously ill that she was unable to walk for months. This
was the first of a series of illnesses which were to make her an invalid
much of her life.

Though this experience saddened Lee at the time, it made his home
the more dear to him. It was about this time that he wrote to a
friend: “The Country looks very sweet now, and the hill at Arlington

You might also like