Book description
Innovative JavaScript behaviors are the hallmark of Web 2.0 interface designs. Visit Apple, Facebook, Microsoft, or any other web titan, and you will find JavaScript implementations providing a smooth, tactile, engaging web experience. Knowledge of JavaScript is essential for developing modern, interactive, sticky web sites, but many beginners are put off by the daunting need to learn a programming language before they can achieve anything.
This book takes a practical approach by showing you how to use JavaScript in simple stages, starting with the basics of storing and manipulating data and moving on to reacting to events and using JavaScript to alter CSS and HTML on the fly. It assumes no prior knowledge of JavaScript, and avoids bombarding you with unnecessary technical details.
At the same time, it explains the main points and acts as a reference that you can come back to when you need to refresh your memory. More advanced concepts are introduced gradually, so that by the end of the book you'll have a solid understanding of all the main aspects of JavaScript. Particular attention is paid to debugging and avoiding common beginners' pitfalls, enabling you to create web sites that not only look good, but are dynamic and exciting for visitors.
Requires no previous knowledge of JavaScript
Gives you instant results—starts showing how to change values and react to events stage by stage
Doesn't bombard you with endless rules and jargon
Table of contents
- Copyright
- About the Author
- About the Technical Reviewers
- Acknowledgments
- Preface
- 1. Representing Data with Values
- 2. Type Conversion
-
3. Operators
- 3.1. Introducing Operator Precedence and Associativity
-
3.2. Using JavaScript Operators
- 3.2.1. Combining Math and Assignment Operations
- 3.2.2. Incrementing or Decrementing Values
- 3.2.3. Testing for Equality
- 3.2.4. Testing for Inequality
- 3.2.5. Comparing Objects, Arrays, and Functions
- 3.2.6. Determining Whether One Number or String Is Greater Than Another
- 3.2.7. Determining Whether One Number or String Is Less Than Another
- 3.2.8. Greater Than or Equal to, Less Than or Equal to
- 3.2.9. Creating More Complex Comparisons
- 3.2.10. Saying or With ||
- 3.2.11. Saying "and" with &&
- 3.2.12. Chaining || Expressions
- 3.2.13. Chaining && Expressions
- 3.2.14. Chaining || and && Expressions
- 3.2.15. Conditionally Returning One of Two Values
- 3.2.16. Making Two Expressions Count as One
- 3.2.17. Deleting a Member, Element, or Variable
- 3.3. Summary
- 4. Controlling Flow
- 5. Member Inheritance
-
6. Functions and Arrays
- 6.1. Why Use Functions?
- 6.2. Functions Are Values
- 6.3. Function Members
- 6.4. Conditional Advance Loading
- 6.5. Lazy Loading
- 6.6. Recursion
- 6.7. Borrowing Methods with apply() or call()
- 6.8. Currying
- 6.9. Chaining Methods
- 6.10. Closure and Returning Functions
- 6.11. Passing a Configuration Object
- 6.12. Callback Functions
- 6.13. Memoization
- 6.14. Global Abatement with Modules
-
6.15. Arrays
- 6.15.1. Plucking Elements from an Array
- 6.15.2. Adding Elements to an Array
- 6.15.3. Gluing Two Arrays Together
- 6.15.4. Reversing the Elements in an Array
- 6.15.5. Sorting the Elements in an Array
- 6.15.6. Creating a String from an Array
- 6.15.7. Taking a Slice of an Array
- 6.15.8. Converting a Read-only Array-like Object to an Array
- 6.15.9. Inserting or Deleting Elements from an Array
- 6.16. Summary
-
7. Traversing and Modifying the DOM Tree
-
7.1. DOM Tree
- 7.1.1. Is Every Node the Same?
- 7.1.2. Interfaces Are Sensibly Named
- 7.1.3. Querying the DOM Tree
- 7.1.4. Same Jargon as for a Family Tree
- 7.1.5. Traversing the DOM Tree
- 7.1.6. Descending with childNodes
- 7.1.7. Ascending with parentNode
- 7.1.8. Muddying the Waters with Whitespace
- 7.1.9. Coding Cascade Style
- 7.1.10. Moving Laterally
- 7.1.11. Converting a NodeList to an Array
- 7.1.12. Converting a NodeList to an Array for Internet Explorer
- 7.1.13. Traversing the DOM without childNodes
- 7.1.14. Finding an Element by ID
- 7.1.15. Finding Elements by Their Tag Names
- 7.1.16. Finding Elements by Class
- 7.1.17. Querying Attributes Like a Member
- 7.1.18. Querying Attributes with Methods
- 7.1.19. Querying Attr Nodes
- 7.1.20. Enumerating Attributes for an Element
- 7.1.21. Creating Element or Text Nodes
- 7.1.22. Deleting Content
- 7.1.23. Copying Content
- 7.1.24. Creating Elements with a Helper Function
- 7.1.25. Reordering Nested Lists
- 7.1.26. Where Did the Formatting Text Nodes Go?
- 7.2. Summary
-
7.1. DOM Tree
-
8. Scripting CSS
- 8.1. DOM Interfaces for Working with CSS
- 8.2. Clarifying Some CSS Jargon
- 8.3. Downloading the Sample Files
- 8.4. Querying a Style Attribute
- 8.5. Scripting Classes
- 8.6. Scripting Rules
- 8.7. Scripting Imported Style Sheets
- 8.8. Adding or Deleting a Rule
- 8.9. Querying Overall Styles from the Cascade
- 8.10. Enabling and Disabling Style Sheets
- 8.11. Including or Importing Style Sheets
- 8.12. Embedding a Style Sheet
- 8.13. Summary
-
9. Listening for Events
- 9.1. Working with the Event Object
- 9.2. Downloading Project Files
- 9.3. Advance Conditional Loading
- 9.4. Telling JavaScript to Stop Listening for an Event
- 9.5. Preventing Default Actions from Taking Place
- 9.6. Preventing an Event from Traversing the DOM Tree
- 9.7. Writing Helper Functions
- 9.8. Sliding Sprites
- 9.9. Drag-and-Drop Behavior
- 9.10. Swapping Skins by Key
- 9.11. Initiating Behaviors When the DOM Tree Is Available
- 9.12. Fighting Global Evil
- 9.13. Summary
-
10. Scripting BOM
- 10.1. Downloading the Project Files
- 10.2. Remembering Visitor Data with Cookies
- 10.3. Animating with Timers
- 10.4. Writing Dynamic Pages Using Ajax
- 10.5. Yielding with Timers
- 10.6. Converting function declarations to expressions
- 10.7. Summary
Product information
- Title: JavaScript for Absolute Beginners
- Author(s):
- Release date: December 2010
- Publisher(s): Apress
- ISBN: 9781430272199
You might also like
video
JavaScript for Beginners
Master JavaScript basics and become a JavaScript developer! Whether you want a career in front-end or …
book
Javascript Absolute Beginner's Guide, 3rd Edition
Make the most of today's JavaScript--even if youve never programmed anything before. JavaScript Absolute Beginner's Guide, …
book
JavaScript Absolute Beginner's Guide, 2nd Edition
Who knew how simple using JavaScript could be? Make the most of JavaScript--even if you've never …
video
JavaScript for Beginners: Learn with 6 Main Projects
This course will guide you on your journey to becoming a confident JavaScript developer by equipping …