JavaScript: Novice to Ninja, 2nd Edition

Book description

JavaScript is a must-have skill for all web developers. JavaScript: Novice to Ninja is a fun, practical, and comprehensive guide to the modern usage of this deceptively powerful language. Comprehensively updated to cover ECMAScript 6 and modern JavaScript development, the second edition of this step-by-step introduction to coding in JavaScript will show you how to to solve real-world problems, design eye-catching animations, build smarter forms, and develop richer applications.

  • Learn the basics of JavaScript programming: functions, methods, properties, loops and logic
  • Use events to track user interactions
  • Build smarter web forms that improve the user experience
  • Work with the document object model (DOM) and Ajax to dynamicall update your pages
  • Add functionality to your apps using HTML5's powerful APIs
  • Use Test Driven Development methodology to write more robust code
  • Build a complete, working JavaScript quiz app from scratch

Publisher resources

View/Submit Errata

Table of contents

  1. JavaScript: Novice to Ninja 2nd Edition
  2. Notice of Rights
  3. Notice of Liability
  4. Trademark Notice
  5. About Darren Jones
  6. About SitePoint
  7. Preface
    1. Who Should Read This Book
    2. Conventions Used
      1. Code Samples
      2. Tips, Notes, and Warnings
    3. Supplementary Materials
  8. Chapter 1: Hello, JavaScript
    1. Programming
    2. JavaScript
    3. The History of JavaScript
    4. The Browser Wars
    5. Web 2.0
    6. Standards
    7. HTML5
    8. Node.js
    9. JavaScript Versions
    10. The Future of JavaScript
    11. A Ninja Programming Environment
    12. Installing Node
      1. Node Installer
      2. Node Version Manager
    13. JavaScript In The Console
    14. Text Editors
      1. Online Options
    15. Your First JavaScript Program
    16. JavaScript in the Browser
    17. Three Layers of the Web
    18. Unobtrusive JavaScript
    19. Graceful Degradation and Progressive Enhancement
    20. Your Second JavaScript Program
    21. Don't Break the Web
    22. The Project: Quiz Ninja
    23. Chapter Summary
  9. Chapter 2: Programming Basics
    1. Comments
    2. JavaScript Grammar
    3. Reserved Words
    4. Primitive Data Types
    5. Variables
      1. Declaring and Assigning
      2. Scope
      3. Global Scope
      4. Local Scope
    6. Naming Constants & Variables
    7. Direct Assignment and Assignment By Reference
    8. Strings
    9. String Properties and Methods
    10. Template Literals
    11. Symbols
    12. Numbers
      1. Octal and Hexadecimal Numbers
      2. Exponential Notation
    13. Number Methods
      1. Arithmetic Operations
    14. Changing The Value of Variables
      1. Incrementing Values
      2. Infinity
      3. NaN
      4. Checking a Value is a Number
    15. Type Coercion
    16. Converting Between Strings and Numbers
      1. Converting Strings to Numbers
      2. Converting Numbers to Strings
      3. Parsing Numbers
    17. Undefined
    18. Null
    19. Booleans
    20. Logical Operators
      1. ! (Logical NOT)
      2. && (Logical AND)
      3. || (Logical OR)
      4. Lazy Evaluation
    21. Bitwise Operators
      1. Bitwise NOT
      2. Bitwise AND
      3. Bitwise OR
      4. Bitwise XOR
      5. Bitwise Shift Operators
    22. Comparison
      1. Equality
      2. Soft Equality
      3. Hard Equality
      4. Inequality
      5. Greater Than and Less Than
    23. Quiz Ninja Project
    24. Chapter Summary
  10. Arrays, Logic, and Loops
    1. Arrays
      1. Initializing an Array
      2. Adding Values to Arrays
      3. Creating Array Literals
      4. Removing Values from Arrays
      5. Destructuring Arrays
      6. Array Properties and Methods
      7. Pop, Push, Shift, and Unshift
      8. Merging Arrays
      9. The join() Method
      10. Slicing and Splicing
      11. Reverse
      12. Sort
      13. Finding if a Value is in an Array
      14. Multidimensional Arrays
    2. Sets
      1. Creating Sets
      2. Adding Values to Sets
      3. Set Methods
      4. Removing Values From Sets
    3. Converting Sets to Arrays
      1. Weak Sets
    4. Maps
      1. Creating Maps
      2. Adding Entries To Maps
      3. Map Methods
      4. Removing Entries From Maps
    5. Converting Maps to Arrays
      1. Weak Maps
    6. Logic
      1. if Statements
      2. else Statements
      3. Ternary Operator
      4. Switch Statements
    7. Loops
      1. While Loops
      2. Infinite Loops
      3. do ... while Loops
      4. For Loops
      5. Nested for Loops
      6. Looping over Arrays
      7. Looping Over Sets
      8. Looping Over Maps
    8. Quiz Ninja Project
    9. Chapter Summary
  11. Functions
    1. Defining a Function
      1. Function Declarations
      2. Function Expressions
      3. Function() Constructors
    2. Invoking a Function
    3. Return Values
    4. Parameters and Arguments
      1. Variable Numbers of Arguments
      2. Improved Mean Function
      3. Default Parameters
      4. Arrow Functions
      5. Function Hoisting
      6. Variable Hoisting
    5. Callbacks
      1. Sorting Arrays With A Callback
    6. Array Iterators
      1. forEach()
      2. map()
      3. Reduce()
      4. Filter()
      5. Chaining Iterators Together
      6. Improving the mean() Function
    7. Quiz Ninja Project
    8. Chapter Summary
  12. Objects
    1. Object Literals
      1. A Super Example
    2. Creating Objects
      1. Accessing Properties
      2. Computed Properties
    3. Calling Methods
    4. Checking if Properties or Methods Exist
    5. Finding all the Properties of an Object
      1. Adding Properties
      2. Changing Properties
    6. Removing Properties
    7. Nested Objects
      1. Objects as Parameters to Functions
      2. this
    8. Namespacing
    9. Built-in Objects
      1. JSON
      2. The Math Object
      3. The Date Object
      4. The RegExp Object
      5. Basic Regular Expressions
    10. Character Groups
      1. Regular Expression Properties
      2. Special Characters
      3. Modifiers
      4. Greedy and Lazy Modifiers
      5. A Practical Example
      6. String Methods
    11. Quiz Ninja Project
    12. Chapter Summary
  13. The Document Object Model
    1. The Document Object Model
      1. What is the DOM?
    2. History of the DOM
    3. An Example Web Page
    4. Getting Elements
      1. Legacy DOM Shortcut Methods
      2. Getting An Element By Its ID
      3. Get Elements By Their Tag Name
      4. Get Elements By Their Class Name
      5. Query Selectors
      6. Navigating the DOM Tree
      7. Finding the Value of a Node
      8. Getting and Setting Attributes
    5. Setting An Element’s Attributes
      1. Classes Of An Element
      2. Creating Dynamic Markup
      3. Replacing Elements on a Page
      4. Live Collections
    6. Updating CSS
      1. Camel Case Properties
      2. Disappearing Act
      3. Checking Style Properties
      4. Use with Caution
    7. Quiz Ninja Project
    8. Chapter Summary
  14. Events
    1. Event Listeners
      1. Inline Event Handlers
      2. Older Event Handlers
      3. Using Event Listeners
    2. Example Code
    3. The Event Object
      1. Types of Event
      2. The Event Target
      3. Coordinates of an Event
    4. Types of Events
      1. Mouse Events
      2. Keyboard Events
      3. Modifier Keys
      4. Touch Events
      5. Touch Event Properties
    5. Removing Event Listeners
    6. Stopping Default Behavior
    7. Event Propagation
      1. Bubbling
      2. Capturing
      3. Stopping the Bubbling Phase
    8. Event Delegation
    9. Quiz Ninja Project
    10. Chapter Summary
  15. Forms
    1. Forms
    2. A Searching Example
      1. Accessing Form Elements
      2. Form Properties and Methods
      3. Form Events
      4. Submitting a Form
      5. Retrieving and Changing Values From a Form
      6. Form Controls
    3. Input Fields
      1. Text Input Fields
      2. Password Input Fields
      3. Checkbox Input Fields
      4. Radio Button Input Fields
      5. Hidden Input Fields
      6. File Input Fields
      7. Other Input Types
      8. Select Drop-Down List
      9. Text Areas
      10. Buttons
    4. I Need a Hero!
    5. Form Validation
      1. Disabling the Submit Button
    6. Quiz Ninja Project
    7. Chapter Summary
  16. The Window Object
    1. The Browser Object Model
      1. Going Global
      2. Dialogs
    2. Browser Information
      1. Which Browser?
      2. Location, Location, Location
    3. The Browser History
    4. Controlling Windows
    5. Screen Information
    6. The Document Object
      1. document.write()
      2. Cookies
      3. Deleting Cookies
    7. Timing Functions
      1. setTimeout()
    8. setInterval()
      1. Animation
      2. requestAnimationFrame
    9. Quiz Ninja Project
    10. Chapter Summary
  17. Testing and Debugging
    1. Errors, Exceptions, and Warnings
      1. Exceptions
      2. Stack Traces
      3. Warnings
    2. The Importance of Testing and Debugging
    3. Strict Mode
      1. Linting Tools
    4. Feature Detection
    5. Debugging in the Browser
      1. The Trusty Alert
      2. Using the Console
      3. Debugging Tools
    6. Error Objects
      1. Throwing Exceptions
    7. Exception Handling
      1. try, catch, and finally
    8. Tests
      1. Test-driven Development
      2. Testing Frameworks
      3. Jest
      4. Crunching Some Numbers
    9. Quiz Ninja Project
    10. Chapter Summary
  18. Further Functions
    1. Function Properties and Methods
      1. Call and Apply Methods
      2. Custom Properties
    2. Immediately Invoked Function Expressions
      1. Temporary Variables
      2. Initialization Code
      3. Safe Use of Strict Mode
      4. Creating Self-contained Code Blocks
    3. Functions that Define and Rewrite Themselves
      1. Init-Time Branching
    4. Recursive Functions
    5. Callbacks
      1. Event-driven Asynchronous Programming
      2. Callback Hell
      3. Promises
      4. Chaining Multiple Promises
      5. Async Functions
      6. Generalized Functions
      7. Functions That Return Functions
    6. Closures
      1. Function Scope
      2. Returning Functions
      3. A Practical Example
      4. A Counter Example
      5. Generators
    7. Functional Programming
      1. Pure Functions
      2. Higher-Order Functions
      3. Currying
      4. A General Curry Function
    8. Getting Functional
    9. Quiz Ninja Project
    10. Chapter Summary
  19. Object-Oriented Programming in JavaScript
    1. Object-Oriented Programming
      1. Encapsulation
      2. Polymorphism
      3. Inheritance
      4. Classes
    2. Constructor Functions
      1. ES6 Class Declarations
      2. The Constructor Property
    3. Static Methods
    4. Prototypal Inheritance
      1. The Prototype Property
      2. Finding Out the Prototype
      3. Own Properties and Prototype Properties
      4. The Prototype Is Live!
      5. Overwriting Prototype Properties
      6. What Should the Prototype Be Used For?
    5. Public and Private Methods
    6. Inheritance
      1. The Prototype Chain
    7. The Object Constructor
      1. Enumerable Properties
      2. Inheritance Using extends
    8. Polymorphism
    9. Adding Methods to Built-in Objects
    10. Property Attributes and Descriptors
      1. Getting and Setting Property Descriptors
      2. Getters and Setters
    11. Creating Objects from Other Objects
      1. Object-Based Inheritance
      2. Object Prototype Chain
    12. Mixins
      1. Using Mixins to Add Properties
      2. Using Mixins to Create a copy() Function
      3. Factory Functions
      4. Using the Mixin Function to Add Modular Functionality
    13. Chaining Functions
    14. Binding this
      1. Use that = this
      2. Use bind(this)
      3. Use for-of Instead Of forEach()
      4. Use Arrow Functions
    15. Borrowing Methods from Prototypes
      1. Borrowing Array Methods
    16. Composition Over Inheritance
    17. Quiz Ninja Project
    18. Chapter Summary
  20. Ajax
    1. Clients and Servers
    2. A Brief History of Ajax
    3. The Fetch API
      1. Basic Usage
      2. Response Interface
      3. Request Interface
      4. Headers Interface
      5. Putting It All Together
    4. Receiving Information
    5. Sending Information
    6. FormData
    7. A Living Standard
    8. Quiz Ninja Project
    9. Chapter Summary
  21. HTML5 APIs
    1. HTML5
    2. The data- Attribute
    3. HTML5 APIs
      1. HTML5 Web Storage
      2. Geolocation
      3. Web Workers
      4. Websockets
      5. Notifications
      6. Multimedia
    4. Other APIs
    5. Drawing with Canvas
    6. Shims and Polyfills
    7. Quiz Ninja Project
    8. Chapter Summary
  22. Modern JavaScript Development
    1. Libraries
      1. DOM Manipulation Example
      2. jQuery
      3. Underscore & Lodash
      4. Advantages and Disadvantages of Libraries
      5. When to Use a Library
      6. Finding Libraries
    2. Modular JavaScript
      1. ES6 Modules
      2. Node.js Modules
    3. MVC Frameworks
      1. A Quick List Example
      2. MV* Frameworks
    4. Templates
      1. Web Components
      2. View Libraries
    5. Package Managers
      1. npm
      2. Searching for Packages
      3. npm init
      4. Aliases
      5. Yarn
      6. Content Delivery Networks
    6. Deploying JavaScript
      1. Transpiling Code
      2. Minification
      3. Folder Structure
      4. Webpack
    7. Quiz Ninja Project
    8. Chapter Summary
  23. Next Steps
    1. What’s Next For JavaScript?
      1. WebAssembly
      2. JavaScript Fatigue
    2. Ninja Skills
      1. Version Control
      2. Keep Your Knowledge Up to Date
      3. Use Common JavaScript Coding Patterns
      4. Build Things
    3. Pair Programming
      1. Contribute to Open Source Projects
    4. JavaScript Development Ideas
      1. HTML5 Game Development
    5. Single-page Web Applications
      1. Progressive Web Applications
      2. Mobile App Development
      3. Desktop App Development
      4. Node.js Development
      5. And There’s More!
    6. Chapter Summary

Product information

  • Title: JavaScript: Novice to Ninja, 2nd Edition
  • Author(s): Darren Jones
  • Release date: September 2017
  • Publisher(s): SitePoint
  • ISBN: 9781492064237