ebook img

Secrets of the JavaScript Ninja PDF

670 Pages·2016·17.35 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Secrets of the JavaScript Ninja

Secrets of the JavaScript Ninja, Second Edition John Resig Bear Bibeault Josip Maras Copyright For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email: [email protected] ©2016 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Development editor: Dan Maharry Technical development editor: Gregor Zurowski Review editor: Ozren Harlovic Project editor: Tiffany Taylor Copy editor: Sharon Wilkey Proofreader: Alyson Brener Technical proofreaders: Mathias Bynens, Jon Borgman Typesetter: Gordan Salinovic Cover designer: Marija Tudor ISBN 9781617292859 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – EBM – 21 20 19 18 17 16 Brief Table of Contents Copyright Brief Table of Contents Table of Contents ES6 cheat sheet Praise for the First Edition Author’s Introduction Acknowledgments About this Book About the Cover Illustration 1. Warming up Chapter 1. JavaScript is everywhere Chapter 2. Building the page at runtime 2. Understanding functions Chapter 3. First-class functions for the novice: definitions and arguments Chapter 4. Functions for the journeyman: understanding function invocation Chapter 5. Functions for the master: closures and scopes Chapter 6. Functions for the future: generators and promises 3. Digging into objects and fortifying your code Chapter 7. Object orientation with prototypes Chapter 8. Controlling access to objects Chapter 9. Dealing with collections Chapter 10. Wrangling regular expressions Chapter 11. Code modularization techniques 4. Browser reconnaissance Chapter 12. Working the DOM Chapter 13. Surviving events Chapter 14. Developing cross-browser strategies Appendix A. Additional ES6 features Appendix B. Arming with testing and debugging Appendix C. Exercise answers Index List of Figures List of Tables List of Listings Table of Contents Copyright Brief Table of Contents Table of Contents ES6 cheat sheet Praise for the First Edition Author’s Introduction Acknowledgments About this Book About the Cover Illustration 1. Warming up Chapter 1. JavaScript is everywhere 1.1. Understanding the JavaScript language 1.1.1. How will JavaScript evolve? 1.1.2. Transpilers give us access to tomorrow’s JavaScript today 1.2. Understanding the browser 1.3. Using current best practices 1.3.1. Debugging 1.3.2. Testing 1.3.3. Performance analysis 1.4. Boosting skill transferability 1.5. Summary Chapter 2. Building the page at runtime 2.1. The lifecycle overview 2.2. The page-building phase 2.2.1. Parsing the HTML and building the DOM 2.2.2. Executing JavaScript code 2.3. Event handling 2.3.1. Event-handling overview 2.3.2. Registering event handlers 2.3.3. Handling events 2.4. Summary 2.5. Exercises 2. Understanding functions Chapter 3. First-class functions for the novice: definitions and arguments 3.1. What’s with the functional difference? 3.1.1. Functions as first-class objects 3.1.2. Callback functions 3.2. Fun with functions as objects 3.2.1. Storing functions 3.2.2. Self-memoizing functions 3.3. Defining functions 3.3.1. Function declarations and function expressions 3.3.2. Arrow functions 3.4. Arguments and function parameters 3.4.1. Rest parameters 3.4.2. Default parameters 3.5. Summary 3.6. Exercises Chapter 4. Functions for the journeyman: understanding function invocation 4.1. Using implicit function parameters 4.1.1. The arguments parameter 4.1.2. The this parameter: introducing the function context 4.2. Invoking functions 4.2.1. Invocation as a function 4.2.2. Invocation as a method 4.2.3. Invocation as a constructor 4.2.4. Invocation with the apply and call methods 4.3. Fixing the problem of function contexts 4.3.1. Using arrow functions to get around function contexts 4.3.2. Using the bind method 4.4. Summary 4.5. Exercises Chapter 5. Functions for the master: closures and scopes 5.1. Understanding closures 5.2. Putting closures to work 5.2.1. Mimicking private variables 5.2.2. Using closures with callbacks 5.3. Tracking code execution with execution contexts 5.4. Keeping track of identifiers with lexical environments 5.4.1. Code nesting 5.4.2. Code nesting and lexical environments 5.5. Understanding types of JavaScript variables 5.5.1. Variable mutability 5.5.2. Variable definition keywords and lexical environments 5.5.3. Registering identifiers within lexical environments 5.6. Exploring how closures work 5.6.1. Revisiting mimicking private variables with closures 5.6.2. Private variables caveat 5.6.3. Revisiting the closures and callbacks example 5.7. Summary 5.8. Exercises Chapter 6. Functions for the future: generators and promises 6.1. Making our async code elegant with generators and promises 6.2. Working with generator functions 6.2.1. Controlling the generator through the iterator object 6.2.2. Using generators 6.2.3. Communicating with a generator 6.2.4. Exploring generators under the hood 6.3. Working with promises 6.3.1. Understanding the problems with simple callbacks 6.3.2. Diving into promises 6.3.3. Rejecting promises 6.3.4. Creating our first real-world promise 6.3.5. Chaining promises 6.3.6. Waiting for a number of promises 6.4. Combining generators and promises 6.4.1. Looking forward—the async function

Description:
Summary More than ever, the web is a universal platform for all types of applications, and JavaScript is the language of the web. If you're serious about web development, it's not enough to be a decent JavaScript coder. You need to be ninja-stealthy, efficient, and ready for anything. This book show
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.