Speaking JavaScript
Axel Rauschmayer
Beijing Cambridge Farnham Kln Sebastopol Tokyo
Praise for Speaking JavaScript
A lot of people think JavaScript is simple and in many cases it is. But in its elegant simplicity lies a deeper functionality that if leveraged properly, can produce amazing results. Axels ability to distill this into an approachable reference will certainly help both aspiring and experienced developers achieve a better understanding of the language.
Rey Bango Advocate for cross-browser development, proponent of the open web, and lover of the JavaScript programming language
Axels writing style is succinct, to the point, yet at the same time extremely detailed. The many code examples make even the most complex topics in the book easy to understand.
Mathias Bynens Belgian web standards enthusiast who likes HTML, CSS, JavaScript, Unicode, performance, and security
" Speaking JavaScript is a modern, up to date book perfectly aimed at the existing experienced programmer ready to take a deep dive into JavaScript. Without wasting time on laborious explanations, Dr. Rauschmayer quickly cuts to the core of JavaScript and its various concepts and gets developers up to speed quickly with a language that seems intent on taking over the developer world.
Peter Cooper Publisher, entrepreneur, and co-organizer of Fluent Conference
If you have enjoyed Axels blog, then youll love this book. His book is filled with tons of bite-sized code snippets to aid in the learning process. If you want to dive deep and understand the ins and outs of JavaScript, then I highly recommend this book.
Elijah Manor Christian, family man, and front end web developer for Dave Ramsey; enjoys speaking, blogging, and tweeting
This book opens the door into the modern JavaScript community with just enough background and plenty of in-depth introduction to make it seem like youve been with the community from the start.
Mitch Pronschinske DZone Editor
After following Dr. Axel Rauschmayers work for a few years, I was delighted to learn that he was writing a book to share his deep expertise of JavaScript with those getting started with the language. Ive read many JavaScript books, but none that show the attention to detail and comprehensiveness of Speaking JS, without being boring or overwhelming. Ill be recommending this book for years to come.
Guillermo Rauch Speaker, creator of socket.io, mongoose, early Node.js contributor, author of Smashing Node.js, founder of LearnBoost/Cloudup (acq. by Wordpress in 2013), and Open Academy mentor
Preface
Due to its prevalence on the Web and other factors, JavaScript has become hard to avoid. That doesnt mean that it is well liked, though. With this book, Im hoping to convince you that, while you do have to accept a fair amount of quirks when using it, JavaScript is a decent language that makes you very productive and can be fun to program in.
Even though I have followed its development since its birth, it took me a long time to warm up to JavaScript. However, when I finally did, it turned out that my prior experience had already prepared me well, because I had worked with Scheme, Java (including GWT), Python, Perl, and Self (all of which have influenced JavaScript).
In 2010, I became aware of Node.js, which gave me hope that Id eventually be able to use JavaScript on both server and client. As a consequence, I switched to JavaScript as my primary programming language. While learning it, I started writing a book chronicling my discoveries. This is the book you are currently reading. On my blog, I published parts of the book and other material on JavaScript. That helped me in several ways: the positive reaction encouraged me to keep going and made writing this book less lonely; comments to blog posts gave me additional information and tips (as acknowledged everywhere in this book); and it made people aware of my work, which eventually led to OReilly publishing this book.
Therefore, this book has been over three years in the making. It has profited from this long gestation period, during which I continually refined its contents.Im glad that the book is finally finished and hope that people will find it useful for learning JavaScript. OReilly has agreed to make it available to be read online, for free, which should help make it accessible to a broad audience.
What You Need to Know About This Book
Is this book for you? The following items can help you determine that:
Who this book is for
This book has been written for programmers, by a programmer. So, in order to understand it, you should already know object-oriented programming, for example, via a mainstream programming language such as Java, PHP, C++, Python, Ruby, Objective-C, C#, or Perl.
Thus, the books target audience is programmers who want to learn JavaScript quickly and properly, and JavaScript programmers who want to deepen their skills and/or look up specific topics.
Whats not covered This book focuses on the JavaScript language proper. For example, you wont find information on programming web browsers (DOM, asynchronous programming, etc.). However, points to relevant material. How this book is organized
This book is divided into four parts, but the main two are:
- JavaScript Quick Start
- JavaScript in Depth
These parts are completely independent! You can treat them as if they were separate books: the former is more like a guide, the latter is more like a reference. tells you more about the structure of this book.
What JavaScript version this book uses This book teaches ECMAScript 5, the current version of JavaScript that is supported by all modern engines. If you have to work with, say, older web browsers, then
Tips for Reading This Book
The most important tip for learning JavaScript is dont get bogged down by the details . Yes, there are many details when it comes to the language, and this book covers most of them. But there is also a relatively simple and elegant big picture that I will point out to you.
The Four Parts of This Book
This book is organized into four parts:
This part teaches you Basic JavaScript, a subset of JavaScript that is as small as possible while still enabling you to be productive. The part stands on its own; it doesnt depend on other parts and no other parts depend on it.This part puts JavaScript in historical and technical context: When, why, and how was it created? How is it related to other programming languages? What were the important steps that got us to where we are today?This part is more of a reference: look for a topic that you are interested in, jump in, and explore. Many short examples should prevent things from becoming too dry.This part gives tips for using JavaScript: best practices, advanced techniques, and learning resources. It also describes a few important tools and libraries.
JavaScript Command Lines
While reading this book, you may want to have a command line ready. That allows you to try out code interactively. The most popular choices are:
Node.js Node.js comes with an interactive command line. You start it by calling the shell command node
. Browsers All major browsers have consoles for entering JavaScript that is evaluated in the context of the current page. Simply search online for the name of your browser and console.