Table of Contents
(→ denotes a BREADTH chapter; ↓ denotes a DEPTH chapter)

Preface    xv
  1 Computer Basics    1
  2 HTML and Web Pages    19
  3 The Internet and the Web    43
  4 JavaScript and Dynamic Web Pages    61
  5 JavaScript and User Interaction    79
  6 The History of Computers    100
  7 Functions and Randomness    119
  8 Algorithms and Programming Languages    136
  9 Abstraction and Libraries    155
10 Computer Science as a Discipline    174
11 Conditional Execution    195
12 Data Representation    216
13 Conditional Repetition    233
14 Inside the Computer - The von Neumann Architecture    253
15 JavaScript Strings    273
16 Inside the Computer - Transistors and Integrated Circuits    293
17 JavaScript Arrays    311
18 Computers and Society    335
Appendix A: Browser Basics    352
Appendix B: Common Text Editors    358
Appendix C: HTML Reference    363
Appendix D: JavaScript Reference    366
Appendix E: random.js Library    373
Appendix F: time.js Library    374
Appendix G: arrays.js Library    376
Index    379
Credits    396
Trademark Information    398


       Preface    xv
→ 1 Computer Basics    1
What Is a Computer? 1
Hardware 3
    Central Processing Unit (CPU) 4
    Memory 6
    Input/Output devices (I/O) 8
Software 9
    Operating Systems 10
Internet and the Web 12
    Web Browsers and Servers 14
    Web Addresses 14
    Accessing Local Pages 15
Looking Ahead... 16
Chapter Summary 16
Review Questions 17
References 18
↓ 2 HTML and Web Pages    19
HTML Basics 20
    HTML Tags 20
    HTML Elements 21
Document Formatting 22
    Text Spacing 22
    Headings and Alignment 23
    Font Formatting 25
Hypertext and Multimedia 27
    Hyperlinks 27
    Images 28
Lists 30
    Formatting Lists 32
Tables 33
    Table Borders 33
    Table Alignment 34
Making Pages Publicly Viewable 36
Looking Ahead... 37
Chapter Summary 38
Supplemental Material and Exercises 39
→ 3 The Internet and the Web    43
History of the Internet 44
    ARPANet 44
    Growth and Privatization 45
How the Internet Works 48
    Distributed Network 48
    Packet Switching 49
    Internet Protocols: TCP/IP 50
    Domain Names 50
History of the Web 52
    Hypertext and the Web 52
    Mainstream Adoption of the Web 53
    Web Growth 54
How the Web Works 55
    HTML 55
    Web Protocol: HTTP 55
    Caching 56
Looking Ahead... 56
Chapter Summary 57
Review Questions 58
References 59
Endnotes 59
↓ 4 JavaScript and Dynamic Web Pages    61
Dynamic Web Pages 62
    HTML Event Handlers 62
    The onclick Event Handler 65
Interaction via Buttons 66
    Input Buttons 66
Dynamic Text within a Page 69
    Alert Windows 69
    The innerHTML Attribute 70
    Example: Quotations Page 73
Looking Ahead... 75
Chapter Summary 75
Supplemental Material and Exercises 76
↓ 5 JavaScript and User Interaction    79
User Input via Text Boxes 79
    The Text Box Element 80
    Example: Form Letter Page 82
JavaScript Variables 83
    Variables for Reusing Values 84
    Example: Fill-in-the-Blank Story 85
    Variables for Temporary Values 86
Web Pages That Compute 88
    JavaScript Numbers and Expressions 88
    Number Representation 90
    Text Boxes and parseFloat 91
    Example: Grade Calculation 94
Programming Errors and Debugging 94
Looking Ahead... 95
Chapter Summary 95
Supplemental Material and Exercises 96
→ 6 The History of Computers    100
Generation 0: Mechanical Computers (1642-1945) 101
    Programmable Devices 102
    Electromagnetic Relays 104
Generation 1: Vacuum Tubes (1945-1954) 105
    Computing and World War II 106
    The von Neumann Architecture 108
Generation 2: Transistors (1954-1963) 109
    High-Level Programming Languages 110
Generation 3: Integrated Circuits (1963-1973) 110
    Large Scale Integration 111
    Computing for Businesses 111
Generation 4: VLSI (1973-1985) 112
    The Personal Computer Revolution 112
    Object-Oriented Programming 114
Generation 5: Parallel Processing & Networking 1985-????) 114
Looking Ahead... 115
Chapter Summary 115
Review Questions 116
Endnotes 118
References 118
↓ 7 Functions and Randomness    119
Predefined JavaScript Functions 119
    Math Functions 120
    Raising Numbers to a Power 123
    Generating Random Numbers 123
Simple User-Defined Functions 125
    Functions That Simplify 128
Randomness in a Page 129
    Example: Simulated Dice 129
    Example: Random Slide Show 130
    Example: Random Banner Ads 131
Looking Ahead... 133
Chapter Summary 133
Supplemental Material and Exercises 134
→ 8 Algorithms and Programming Languages    136
Algorithms 137
    Algorithms in the Real World 137
Designing and Analyzing Algorithms 138
    An Alternative Algorithm 140
    Algorithm Analysis 141
    Big-Oh Notation 142
Algorithm Example: Searching a List 142
    Sequential Search 142
    Binary Search 143
    Algorithm Analysis 144
Algorithm Example: Approximating a Square Root 144
    Algorithm Analysis 146
Algorithms and Programming 146
    Machine Languages 146
    High-Level Languages 147
    Program Translation 148
    Interpreters and Compilers 150
Looking Ahead... 151
Chapter Summary 151
Review Questions 152
References 153
↓ 9 Abstraction and Libraries    155
The Structure of Functions 156
    Local Variables 157
Functions with Inputs 159
    Multiple Inputs 161
Functions that Return Values 162
    Function Libraries 163
The random.js Library 165
Looking Ahead... 168
Chapter Summary 168
Supplemental Material and Exercises 169
→ 10 Computer Science as a Discipline    174
Computer "Science" 175
    Artificial Science 176
Computer Science Themes 176
    Hardware 177
    Software 177
    Theory 178
Subfields of Computer Science 179
    Algorithms and Data Structures 179
    Architecture 182
    Operating Systems and Networks 183
    Software Engineering 185
    Artificial Intelligence and Robotics 187
    Bioinformatics 188
The Ethics of Computing 189
Looking Ahead... 190
Chapter Summary 191
Review Questions 192
Endnotes 193
References 194
↓ 11 Conditional Execution    195
If Statements 195
    Boolean Tests 196
Nested If Statements 199
    Cascading If-Else Statements 200
Example: Dice Simulations 201
    Counters 201
    Boolean Expressions 204
Example: Slot Machine 206
Looking Ahead... 209
Chapter Summary 209
Supplemental Material and Exercises 210
→ 12 Data Representation    216
Analog vs. Digital 216
Binary Numbers 218
Representing Integers 219
Representing Real Numbers 220
Representing Characters and Strings 222
Representing Other Types of Data 223
    Sounds 223
    Images 225
    Movies 227
How Computers Distinguish among Data Types 228
Looking Ahead... 229
Chapter Summary 230
Review Questions 230
References 232
↓ 13 Conditional Repetition    233
While Loops 234
    Avoiding Redundancy 236
    Example: Lottery Combinations 238
Counter-Driven Loops 240
Variables and Repetition 243
Example: Generating Hailstone Sequences 246
Looking Ahead... 247
Chapter Summary 248
Supplemental Material and Exercises 248
→ 14 Inside the Computer - The von Neumann Architecture    253
CPU Subunits and Datapath 253
    CPU Subunits 254
    CPU Datapath Cycles 255
    Datapath Simulator 255
CPU and Main Memory 257
    Transferring Data to and from Main Memory 257
    Datapath with Memory Simulator 258
Stored-Program Computer 260
    Machine Languages 260
    Control Unit 260
    Stored-Program Computer Simulator 263
    The Role of Input/Output Devices 267
Machine vs. Assembly Languages 268
Looking Ahead... 269
Chapter Summary 270
Review Questions 271
References 272
↓ 15 JavaScript Strings    273
Strings as Objects 273
    Properties and Methods 274
Common String Manipulation Methods 276
    String Concatenation 277
Searching Strings 278
    General Searches 279
String Manipulations and Repetition 280
    Example: Recognizing Palindromes 282
Example: Substitution Ciphers 282
    Encoding Messages 283
    Decoding Messages 286
Looking Ahead... 287
Chapter Summary 288
Supplemental Material and Exercises 288
→ 16 Inside the Computer - Transistors and Integrated Circuits    293
Electricity and Switches 294
    Electricity Basics 294
    Switches 294
    Transistors 295
    Transistors as Switches 296
From Transistors to Gates 297
    Gates and Binary Logic 298
From Gates to Complex Circuits 300
    Example: Designing Memory Circuitry 302
From Circuits to Microchips 303
    The Integrated Circuit 303
    Manufacturing Integrated Circuits 304
    Packaging Microchips 305
Looking Ahead... 307
Chapter Summary 307
Review Questions 308
References 310
↓ 17 JavaScript Arrays    311
Arrays as Objects 312
    Accessing Items in an Array 312
    Assigning Items in an Array 313
From Strings to Arrays 315
    The split Method for Strings 315
    Example: Generating Acronyms 316
Arrays of Numbers 318
    Example: Maintaining Dice Statistics (Approach 1) 321
    Example: Maintaining Dice Statistics (Approach 2) 323
Example: ASCII Animations 324
Looking Ahead... 325
Chapter Summary 327
Supplemental Material and Exercises 328
→ 18 Computers and Society    335
Positive Impact of Technology 335
    Computers and Programs for Everyday Tasks 336
    The Internet and Web as Information Sources 338
    The Internet and Web as Communications Media 341
    The Internet and Web for Commerce 342
Potential Dangers of Technology 344
    Reliance on Complex Systems 344
    Information Overload 345
    Privacy and Security 346
    The Digital Divide 347
Looking Beyond... 348
Chapter Summary 349
Review Questions 349
Endnotes 350
References 351
Appendix A: Browser Basics    352
Appendix B: Common Text Editors    358
Appendix C: HTML Reference    363
Appendix D: JavaScript Reference    366
Appendix E: random.js Library    373
Appendix F: time.js Library    374
Appendix G: arrays.js Library    376
Index    379
Credits    396
Trademark Information    398