O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sams Teach Yourself JavaScript in 24 Hours, Seventh Edition

Book Description

In just 24 lessons of one hour or less, Sams Teach Yourself JavaScript in 24 Hours helps you learn the fundamentals of web programming using the JavaScript language.

 

Designed for beginners with no previous programming experience, this book’s straightforward, step-by-step approach shows you how to use JavaScript to add a wide array of interactive features and effects to your web pages.

 

Every lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success.

 

Step-by-step instructions carefully walk you through the most common JavaScript programming tasks.

Practical, hands-on examples show you how to apply what you learn.

Quizzes and exercises help you test your knowledge and stretch your skills.

 

Learn how to…

· Use JavaScript to build dynamic, interactive web pages

· Debug scripts

· Create scripts that work in all browsers

· Write clear, reliable, and reusable code

· Use object-oriented programming techniques

· Script with the DOM

· Manipulate JSON data

· Work with HTML5 and CSS3

· Control CSS with simple JavaScript code

· Read and write cookies

· Use some of the new ECMAScript features today

· Match patterns using regular expressions

· Understand and use closures

· Organize your code with modules

Table of Contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Contents at a Glance
  5. Table of Contents
  6. About the Author
  7. Accessing the Free Web Edition
  8. Figure Credits
  9. Introduction
    1. Who This Book Is For
    2. Our Aims
    3. Conventions Used
    4. Q&A, Workshop, and Exercises
    5. How Things Are Organized
    6. Tools You’ll Need
  10. Part I: Your First Steps with JavaScript
    1. Lesson 1. Introducing JavaScript
      1. Web Scripting Fundamentals
      2. Summary
      3. Q&A
      4. Workshop
      5. Exercises
    2. Lesson 2. Writing Simple Scripts
      1. Including JavaScript in Your Web Page
      2. Writing JavaScript Statements
      3. Using Variables
      4. Working with Operators
      5. Capturing Mouse Events
      6. Summary
      7. Q&A
      8. Workshop
      9. Exercises
    3. Lesson 3. Introducing Functions
      1. General Syntax
      2. Calling Functions
      3. Summary
      4. Q&A
      5. Workshop
      6. Exercises
    4. Lesson 4. More Fun with Functions
      1. Scope of Variables
      2. Arrow Functions
      3. Setting Default Parameters
      4. Summary
      5. Q&A
      6. Workshop
      7. Exercise
    5. Lesson 5. DOM Objects and Built-in Objects
      1. Interacting with the User
      2. Selecting Elements by Their ID
      3. Accessing Browser History
      4. Using the location Object
      5. Using Dates and Times
      6. Summary
      7. Q&A
      8. Workshop
      9. Exercises
  11. Part II: Cooking with Code
    1. Lesson 6. Dealing with Numbers
      1. Numbers
      2. Global Methods
      3. The Number Object
      4. The Number() Function
      5. Boolean Values
      6. The values null and undefined
      7. Summary
      8. Q&A
      9. Workshop
      10. Exercise
    2. Lesson 7. Working with Character Strings
      1. Strings
      2. Template Strings
      3. Summary
      4. Q&A
      5. Workshop
      6. Exercise
    3. Lesson 8. Storing Data In Arrays
      1. Arrays
      2. How to Iterate Through Arrays
      3. The Three-Dots Operator
      4. Summary
      5. Q&A
      6. Workshop
      7. Exercises
    4. Lesson 9. Handling Events in JavaScript
      1. Types of Events
      2. Event Handlers
      3. The event object
      4. Summary
      5. Q&A
      6. Workshop
      7. Exercises
    5. Lesson 10. Controlling Program Flow
      1. Conditional Statements
      2. Loops and Control Structures
      3. How to Set and Use Timers
      4. Summary
      5. Q&A
      6. Workshop
      7. Exercises
  12. Part III: Understanding JavaScript Objects
    1. Lesson 11. Introducing Object-Oriented Programming
      1. What Is Object-Oriented Programming?
      2. Object Creation
      3. Extending and Inheriting Objects Using prototype
      4. Encapsulation
      5. Summary
      6. Q&A
      7. Workshop
      8. Exercises
    2. Lesson 12. Learning More About Objects
      1. Classes
      2. Object Inheritance
      3. Feature Detection
      4. Summary
      5. Q&A
      6. Workshop
      7. Exercise
    3. Lesson 13. Scripting with the DOM
      1. DOM Nodes
      2. Selecting Elements with getElementsByTagName()
      3. How to Read an Element’s Attributes
      4. Mozilla’s DOM Inspector
      5. Summary
      6. Q&A
      7. Workshop
      8. Exercises
    4. Lesson 14. Meet JSON
      1. What Is JSON?
      2. How to Access JSON Data
      3. Data Serialization with JSON
      4. JSON Data Types
      5. How to Simulate Associative Arrays
      6. How to Create Objects with JSON
      7. JSON Security
      8. Summary
      9. Q&A
      10. Workshop
      11. Exercises
  13. Part IV: Manipulating Web Pages with JavaScript
    1. Lesson 15. Programming HTML with JavaScript
      1. Markup for HTML5
      2. Some Important Elements
      3. Drag and Drop
      4. Local Storage
      5. How to Work with Local Files
      6. Summary
      7. Q&A
      8. Workshop
      9. Quiz
      10. Exercises
    2. Lesson 16. Manipulating CSS in JavaScript
      1. A Ten-Minute CSS Primer
      2. The DOM style Property
      3. How to Access Classes Using className
      4. The DOM styleSheets Object
      5. Summary
      6. Q&A
      7. Workshop
      8. Exercises
    3. Lesson 17. More Advanced Control of CSS
      1. Vendor-Specific Properties and Prefixes
      2. CSS3 Borders
      3. CSS3 Backgrounds
      4. CSS3 Gradients
      5. CSS3 Text Effects
      6. CSS3 Transitions, Transformations, and Animations
      7. How to Reference CSS3 Properties in JavaScript
      8. How to Set CSS3 Properties with Vendor Prefixes
      9. Summary
      10. Q&A
      11. Workshop
      12. Exercises
  14. Part V: Some Advanced Techniques for Your JavaScript Toolkit
    1. Lesson 18. Reading and Writing Cookies
      1. What Are Cookies?
      2. Using the document.cookie Property
      3. Reviewing Cookie Ingredients
      4. Writing a Cookie
      5. Writing a Function to Write a Cookie
      6. Reading a Cookie
      7. Deleting Cookies
      8. Setting Multiple Values in a Single Cookie
      9. Summary
      10. Q&A
      11. Workshop
      12. Exercises
    2. Lesson 19. Matching Patterns Using Regular Expressions
      1. Creating a Regular Expression
      2. Summary
      3. Q&A
      4. Workshop
      5. Exercises
    3. Lesson 20. Understanding and Using Closures
      1. Revisiting Scope
      2. Returning a Function from a Function
      3. Achieving Closure
      4. Summary
      5. Q&A
      6. Workshop
      7. Exercise
    4. Lesson 21. Organizing Code with Modules
      1. Why Use Modules?
      2. Module Basics
      3. Exporting
      4. Importing
      5. Summary
      6. Q&A
      7. Workshop
      8. Exercise
  15. Part VI: Learning the Trade
    1. Lesson 22. Good Coding Practice
      1. Don’t Overuse JavaScript
      2. How to Write Readable and Maintainable Code
      3. Graceful Degradation
      4. Progressive Enhancement
      5. Unobtrusive JavaScript
      6. Feature Detection
      7. How to Handle Errors Well
      8. Summary
      9. Q&A
      10. Workshop
      11. Exercises
    2. Lesson 23. Debugging Your Code
      1. An Introduction to Debugging
      2. More Advanced Debugging
      3. Summary
      4. Q&A
      5. Workshop
      6. Exercise
    3. Lesson 24. Where to Go Next
      1. Why Use a Library?
      2. What Sorts of Things Can Libraries Do?
      3. Some Popular Libraries and Frameworks
      4. A Closer Look at jQuery
      5. The jQuery UI
      6. An Introduction to Ajax
      7. How to Use jQuery to Implement Ajax
      8. A Brief Look at Node.js
      9. Summary
      10. Q&A
      11. Workshop
      12. Exercises
  16. Appendix A. Tools for JavaScript Development
    1. Editors
    2. Validators
    3. Verifying and Testing Tools
  17. Index
  18. Accessing the Free Web Edition
  19. Code Snippets