Prag- matic Guide to JavaScript will take you a big step ahead in programming real-world JavaScript by showing you what is going on behind the scenes in popular JavaScript libraries and [r]
(1)(2)What Readers Are Saying AboutPragmatic Guide to JavaScript I wish I had owned this book when I first started out doing JavaScript! Prag-matic Guide to JavaScriptwill take you a big step ahead in programming real-world JavaScript by showing you what is going on behind the scenes in popular JavaScript libraries and giving you no-nonsense advice and back-ground information on how to the right thing With the condensed years of experience of one of the best JavaScript developers around, it’s a must-read with great reference to everyday JavaScript tasks.
Thomas Fuchs
Creator of the script.aculo.us framework
An impressive collection of very practical tips and tricks for getting the most out of JavaScript in today’s browsers, with topics ranging from fundamen-tals such as form validation and JSON handling to application examples such as mashups and geolocation I highly recommend this book for anyone wanting to be more productive with JavaScript in their web applications.
Dylan Schiemann
CEO at SitePen, cofounder of the Dojo Toolkit
There are a number of JavaScript books on the market today, but most of them tend to focus on the new or inexperienced JavaScript programmer. Porteneuve does no such thing, and this Pragmatic Guide is a better book for it If you’re a novice, go elsewhere first, and then when you have some scripting under your belt, come back; if you’ve worked with JavaScript before, thenPragmatic Guide to JavaScripttakes a set of techniques that you may have heard about or seen and makes them useful to you Recom-mended.
(3)PragmaticGuidetoJavaScript
Christophe Porteneuve
The Pragmatic Bookshelf
(4)Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and The Pragmatic Pro-grammers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linkinggdevice are trademarks of The Pragmatic Programmers, LLC
Every precaution was taken in the preparation of this book However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun For more information, as well as the latest Pragmatic titles, please visit us athttp://www.pragprog.com
The team that produced this book includes: Editor: David McClintock Indexing: Potomac Indexing, LLC Copy edit: Kim Wimpsett Layout: Steve Peter Production: Janet Furlow Customer support: Ellie Callahan International: Juliet Benda
Copyright © 2010 Pragmatic Programmers, LLC All rights reserved
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher
Printed in the United States of America ISBN-10: 1-934356-67-0
(5)Contents
Dedication 9
Acknowledgments 10
Introduction 12
What’s This Book About, and Who Is It For? . 12
This Book and JavaScript Libraries . 13
This Book at a Glance . 14
How to Read This Book . 15
I Bread and Butter: Pure JavaScript 16
Task Dynamically Selecting a Method/Property 18
Task Achieving Code Privacy with the Module Pattern 20 Task Using Optional, Variable, and Named Arguments 22
II The DOM, Events, and Timers 24
Task Obtaining References to DOM Elements 26
Task Dynamically Styling Content 28
Task Changing an Element’s Contents 30
Task Running Code When the DOM Is Loaded 32
Task Listening for Events (and Stopping) 34
Task Leveraging Event Delegation 36
Task 10 Decoupling Behaviors with Custom Events 38
(6)MoreFunWithLanguages
SevenLanguagesinSevenWeeksIn this book you’ll get a hands-on tour of Clojure, Haskell, Io,
Prolog, Scala, Erlang, and Ruby Whether or not your favorite language is on that list, you’ll broaden your perspective of programming by examining these languages side-by-side You’ll learn something new from each, and best of all, you’ll learn how to learn a language quickly
Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages
Bruce A Tate
(300 pages)ISBN: 978-1934356-59-3 $34.95
http://pragprog.com/titles/btlang
LanguageImplementationPatternsLearn to build configuration file readers, data readers, model-driven
code generators, source-to-source translators, source analyzers, and interpreters You don’t need a background in computer
science—ANTLR creator Terence Parr demystifies language implementation by breaking it down into the most common design patterns Pattern by pattern, you’ll learn the key skills you need to implement your own computer languages
Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages
Terence Parr
(350 pages)ISBN: 978-1934356-45-6 $34.95
(7)ThePragmaticBookshelf
The Pragmatic Bookshelf features books written by developers for developers The titles continue the well-known Pragmatic Programmer style and continue to garner awards and rave reviews As development gets more and more difficult, the Pragmatic Programmers will be there with more titles and products to help you stay on top of your game
VisitUsOnline
Pragmatic Guide to JavaScript
http://pragprog.com/titles/pg_js
Source code from this book, errata, and other resources Come give us feedback, too!
Register for Updates
http://pragprog.com/updates
Be notified when updates and new books become available
Join the Community
http://pragprog.com/community
Read our weblogs, join our online discussions, participate in our mailing list, interact with our wiki, and benefit from the experience of other Pragmatic Programmers
New and Noteworthy
http://pragprog.com/news
Check out the latest pragmatic developments, new titles and other offerings
BuytheBook
If you liked this eBook, perhaps you’d like to have a paper copy of the book It’s available for purchase at our store:pragprog.com/titles/pg_js
ContactUs
Online Orders: www.pragprog.com/catalog Customer Service: support@pragprog.com
Non-English Versions: translations@pragprog.com
Pragmatic Teaching: academic@pragprog.com
Author Proposals: proposals@pragprog.com
http://www.pragprog.com. http://pragprog.com/titles/btlang http://pragprog.com/titles/tpdsl http://pragprog.com/titles/pg_js http://pragprog.com/updates http://pragprog.com/community http://pragprog.com/news www.pragprog.com/catalog