Programming with JavaScript: Algorithms and Applications for Desktop and Mobile Browsers

Book description


Used in millions of web pages, JavaScript is an excellent teaching language and ideal for students delving into computer science for the first time. Designed specifically for the CS1 introductory programming course, Programming with JavaScript: Algorithms and Applications for Desktop and Mobile Browsers introduces students to computer science and programming using a modern approach. The text correlates to the ACM/IEEE CS1 course requirements and provides real-world case studies and numerous exercises throughout. The case studies show readers actual examples and their development from inception to final product.

The authors cover unique topics not typically found in an introductory-level text, such as 2D and 3D graphics in web pages, multitouch and gesture interfaces, distributed computing, software engineering fundamentals, and coverage of powerful tools such as jQuery and regular expressions. To stress the importance of hands-on application in learning a programming language, the authors also provide numerous examples of working code, as well as exercises involving modification of that code.

Key Features:
-Addresses the knowledge units from the ACM/IEEE Computer Science Computing Curricula for introductory programming courses, and covers security and net-centric computing topics as recommended in the ACM revised report CC2008.
-Provides a step-by-step introduction to programming in JavaScript.
-Focuses on the basics and functionality of JavaScript and software engineering principles.
-Provides a solid foundation in programming by stressing fundamentals early. This text takes full advantage of the expressive power of JavaScript's object literals and functions-as-values features to give students an early appreciation of the importance of data structures.
-Includes self-contained, functionally complete case studies that illustrate and integrate key concepts while also providing concrete examples of the best practices described in the text.
-Contains numerous exercises throughout for students to immediately test and apply their understanding of the material. The exercises are chosen to represent recognizable applications and use cases from real-world web applications, while also exposing students to additional material that goes beyond what is provided in the chapter.

Table of contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Contents
  5. Preface
  6. 1 The Field of Computing
    1. 1.1 Computing Is a Natural Science
    2. 1.2 The Five Disciplines of Computing
      1. 1.2.1 Computer Science
      2. 1.2.2 Software Engineering
      3. 1.2.3 Computer Engineering
      4. 1.2.4 Information Technology
      5. 1.2.5 Information Systems
    3. 1.3 Careers in Computing
    4. 1.4 Myths about Computing
    5. Exercises
  7. 2 Programming
    1. 2.1 Learning to Program
    2. 2.2 Getting Started
      1. 2.2.1 The Browser Address Box
      2. 2.2.2 Runner Pages
      3. 2.2.3 Interactive Shells
      4. 2.2.4 Files
    3. 2.3 Elements of Programs
      1. 2.3.1 Expression
      2. 2.3.2 Variables
      3. 2.3.3 Statements
    4. 2.4 The Practice of Programming
      1. 2.4.1 Comments
      2. 2.4.2 Coding Conventions
      3. 2.4.3 Code Quality Tools
    5. 2.5 The JavaScript Programming Language
    6. Exercises
  8. 3 Data
    1. 3.1 Data Types
    2. 3.2 Truth Values
    3. 3.3 Numbers
      1. 3.3.1 Numeric Operations
      2. 3.3.2 Size and Precision Limits
      3. 3.3.3 NaN
      4. 3.3.4 Hexadecimal Numerals
    4. 3.4 Text
      1. 3.4.1 Characters, Glyphs, and Character Sets
      2. 3.4.2 String Operations
    5. 3.5 Undefined and Null
    6. 3.6 Objects
      1. 3.6.1 Objects Basics
      2. 3.6.2 Understanding Object References
      3. 3.6.3 Object Prototypes
      4. 3.6.4 Self-Referen tial Objects
    7. 3.7 Arrays
    8. 3.8 Type Conversion
      1. 3.8.1 Weak Typing
      2. 3.8.2 Explicit Conversion
      3. 3.8.3 Loose Equality Operators
    9. 3.9 The typeof Operator*
    10. Exercises
  9. 4 Statements
    1. 4.1 The Declaration Statement
    2. 4.2 The Expression Statement
    3. 4.3 Conditional Execution
      1. 4.3.1 The if Statement
      2. 4.3.2 The Conditional Expression
      3. 4.3.3 The switch Statement
      4. 4.3.4 Avoiding Conditional Code with Lookups
      5. 4.3.5 Short-Circuit Execution
    4. 4.4 Iteration
      1. 4.4.1 The while and do-while Statements
      2. 4.4.2 The for Statement
      3. 4.4.3 The for-in Statement
    5. 4.5 Disruption
      1. 4.5.1 break and continue
      2. 4.5.2 Exceptions
    6. 4.6 Coding Forms to Avoid
      1. 4.6.1 Blockless Compound Statements
      2. 4.6.2 Implicit Semicolon
      3. 4.6.3 Implicit Declarations
      4. 4.6.4 Increment and Decrement Operators
      5. 4.6.5 The with Statement
      6. Exercises
  10. 5 Functions
    1. 5.1 Black Boxes
    2. 5.2 Defining and Calling Functions
    3. 5.3 Examples and More Examples
      1. 5.3.1 Simple One-Line Functions
      2. 5.3.2 Validating Arguments
      3. 5.3.3 Passing Object References as Arguments
      4. 5.3.4Preconditions
      5. 5.3.5 Separation of Concerns
      6. 5.3.6 The Fibonacci Sequence
    4. 5.4 Scope
    5. 5.5 Functions as Objects
      1. 5.5.1 Properties of Functions
      2. 5.5.2 Functions as Properties
      3. 5.5.3 Constructors
    6. 5.6 Context
    7. 5.7 Higher-Order Functions
    8. 5.8 Function Declarations Versus Function Expressions*
    9. Exercises
  11. 6 Events
    1. 6.1 User Interaction
      1. 6.1.1 A Programming Paradigm Shift
      2. 6.1.2 Events by Example: The Temperature Converter Web Page
    2. 6.2 Defining User Interface Elements
      1. 6.2.1 Web Pages Are Structured Documents
      2. 6.2.2 Elements That Produce User Interface Controls
    3. 6.3 Programmatically Accessing User Interface Elements
      1. 6.3.1 The document Object
      2. 6.3.2 Fun with DOM Properties
      3. 6.3.3 A Place to “Play”
      4. 6.3.4 Manipulating User Interface Controls
      5. 6.3.5 Walking the DOM*
    4. 6.4 Event Handlers
      1. 6.4.1 Anatomy of an Event Handler
      2. 6.4.2 Event Handlers Are Functions Are Objects
    5. 6.5 Event Objects
    6. 6.6 Event Implementation Details
      1. 6.6.1 Event Capturing and Bubbling
      2. 6.6.2 Default Actions
      3. 6.6.3 Assigning Event Handlers
      4. 6.6.4Ev ents Based on the Passage of Time
      5. 6.6.5 Multitouch, Gesture, and Physical Events
    7. 6.7 Case Study: Tic-Tac-Toe
      1. 6.7.1 Files and Connections
      2. 6.7.2 Initialization
      3. 6.7.3 Event Handling
      4. 6.7.4The Business Logic
    8. Exercises
  12. 7 Software Construction
    1. 7.1 Software Engineering Activities
    2. 7.2 Object-Oriented Design and Programming
      1. 7.2.1 Families of Objects
      2. 7.2.2 Inheritance
      3. 7.2.3 Information Hiding
      4. 7.2.4Prop erty Descriptors*
    3. 7.3 JavaScript Standard Objects
      1. 7.3.1 Built-in Objects
      2. 7.3.2 Web Browser Host Objects
    4. 7.4 Modules
      1. 7.4.1 Simple Modules
      2. 7.4.2 The Tic-Tac-Toe Game as a Module
    5. 7.5 The jQuery JavaScript Library
    6. 7.6 Performance
      1. 7.6.1 Run-Time Efficiency
      2. 7.6.2 Space Efficiency
      3. 7.6.3 Load-Time Efficiency
      4. 7.6.4User Interface Efficiency
    7. 7.7 Unit Testing
      1. 7.7.1 An Introductory Example
      2. 7.7.2 The QUnit Testing Framework
      3. 7.7.3 Testing in the Software Development Process
    8. Exercises
  13. 8 Distributed Computing
    1. 8.1 Distributed Computing Models
    2. 8.2 Data Interchange Formats
      1. 8.2.1 Plain Text
      2. 8.2.2 XML
      3. 8.2.3 JSON
      4. 8.2.4Y AML
    3. 8.3 Synchronous vs
    4. 8.4 Ajax
      1. 8.4.1 Ajax in jQuery
      2. 8.4.2 Ajax Without a Library
    5. 8.5 Designing Distributed Applications
      1. 8.5.1 Uniform Resource Identifiers
      2. 8.5.2 REST
      3. 8.5.3 Separation of Distributed Application Concerns
      4. 8.5.4 Serv er-Side Technologies*
    6. 8.6 Security
      1. 8.6.1 The Web, the Bad, and the Sandbox
      2. 8.6.2 The Same Origin Policy
      3. 8.6.3 Cross-Site Scripting
      4. 8.6.4 Mash ups
    7. 8.7 Case Study: Events and Trending Topics
      1. 8.7.1 Date Selection User Interface
      2. 8.7.2 Ajax Connection
      3. 8.7.3 Result Processing
      4. 8.7.4Data (Mashup) Display
    8. Exercises
  14. 9 Graphics and Animation
    1. 9.1 Fundamentals
      1. 9.1.1 Coordinate Spaces
      2. 9.1.2 Colors
      3. 9.1.3 Pixels vs
      4. 9.1.4 Animation
    2. 9.2 HTML and CSS
      1. 9.2.1 HTML Elements for Graphics
      2. 9.2.2 CSS
      3. 9.2.3 Visual Properties
      4. 9.2.4 Absolute Position
      5. 9.2.5 Case Study: Bar Chart
      6. 9.2.6 Case Study: Towers of Hanoi Display
    3. 9.3 Animation in HTML and CSS
      1. 9.3.1 Constant Velocity
      2. 9.3.2 Fading In and Out
      3. 9.3.3 Animating Other Properties
      4. 9.3.4 Ramp ed (or Eased) Animation
      5. 9.3.5 Declarative CSS Animation
    4. 9.4 The canvas Element
      1. 9.4.1 Instantiating a canvas
      2. 9.4.2 The Rendering Context
      3. 9.4.3 Drawing Rectangles
      4. 9.4.4 Drawing Lines and Polygons
      5. 9.4.5 Drawing Arcs and Circles
      6. 9.4.6 Drawing B´ezier and Quadratic Curves
      7. 9.4.7 Working with Images
      8. 9.4.8 Transformations
      9. 9.4.9 Animation
      10. 9.4.10 canvas by Example
    5. 9.5 SVG
      1. 9.5.1 Seeing SVG in a Web Browser
      2. 9.5.2 SVG Case Study: A B´ezier Curve Editor
      3. 9.5.3 Objects in the Drawing
      4. 9.5.4Reading and Writing Attributes
      5. 9.5.5 Interactivity (aka Event Handling Redux)
      6. 9.5.6 Other SVG Features
    6. 9.6 3D Graphics with WebGL
      1. 9.6.1 WebGL Is the 3D canvas
      2. 9.6.2 Case Study: The Sierpinski Gasket
      3. 9.6.3 Defining the 3D Data
      4. 9.6.4Shader Code
      5. 9.6.5 Drawing the Scene
      6. 9.6.6 Interactivity and Events
    7. 9.7 Other Client-Side Graphics Technologies
      1. 9.7.1 Flash
      2. 9.7.2 Java
      3. 9.7.3 VML
    8. Exercises
  15. 10 Advanced Topics
    1. 10.1 Regular Expressions
      1. 10.1.1 Introducing Regular Expressions
      2. 10.1.2 Capture
      3. 10.1.3 Quantifiers
      4. 10.1.4 Bac kreferences
      5. 10.1.5 Regex Modifiers
      6. 10.1.6 The RegExp Constructor
      7. 10.1.7 More on Regular Expressions
    2. 10.2 Recursion
      1. 10.2.1 What Is Recursion?
      2. 10.2.2 Classic Examples of Recursion
      3. 10.2.3 Recursion and Family Trees
      4. 10.2.4When Not to Use Recursion
    3. 10.3 Caching
    4. 10.4 MapReduce
      1. 10.4.1 Using map, filter, and reduce
      2. 10.4.2 Implementation
      3. 10.4.3 MapReduce in Large-Scale Data Processing
    5. 10.5 Dynamically Creating Event Handlers
    6. Exercises
  16. A JavaScript Language Reference
  17. B Numeric Encoding
  18. C Unicode
  19. Glossary
  20. Bibliography
  21. Index
  22. Credits

Product information

  • Title: Programming with JavaScript: Algorithms and Applications for Desktop and Mobile Browsers
  • Author(s): John David Dionisio, Ray Toal
  • Release date: December 2011
  • Publisher(s): Jones & Bartlett Learning
  • ISBN: 9781449679477