Preface
The aim of this book is to introduce you to programming using the JavaScript language, eventually helping you to develop into a JavaScript ninja.
This is an exciting time to be learning JavaScript, having finally outgrown its early reputation as a basic scripting language used to produce cringeworthy effects on web pages. Today, JavaScript is used to produce professional and powerful web applications. Modern browsers are now capable of running JavaScript code at lightning speed, and Node.js has helped to revolutionize it by facilitating its use in other environments. This has led to a much more professional and structured approach to building JavaScript applications, where it is now considered a full-fledged programming language. In short, JavaScript has grown up.
JavaScript has a number of cool features that make it stand out from other languages, such as callbacks, first-class functions, prototypal inheritance, and closures. Its event-based model also makes it a very good choice for modern web application development. JavaScripts ace in the pack, though, is something of which every language is enviousits ubiquity . JavaScript is available almost everywhere; anybody who has access to a browser can use it. And this is increasing every year as it becomes more readily available outside the browser environment. This translates into JavaScripts reach being immense: it is already the most popular language on GitHub. I can only see JavaScript growing even more popular in the future as it becomes the language of choice for the Internet of Thingshelping to control household appliances, even program robots.
Before I get carried away, though, I should point out that JavaScript is far from perfect, having a number of flaws. It is missing some important programming constructs, such as modules and private functions, that are considered standard in many modern programming languages. Yet its also an unbelievably flexible language, where many of these gaps can be filled using the tools that it provides. In addition, many libraries have sprung into existence that help to extend JavaScript so that its now able to reach its full potential.
This book starts off with the basics, assuming no programming or JavaScript knowledge, but quickly gets up to speed covering all the main topics in great depth such as functions, objects, and DOM manipulation. More advanced topics such as error handling and testing, functional programming, and OOP are then introduced after the basics have been covered. There have been some exciting new developments in the world of JavaScript over the last few years such as Ajax, HTML5 APIs, and task runners, and these are covered in the last part of the book. Theres also a practical project to build a quiz application that is developed throughout the book towards the end of each chapter. Ive written with developing for modern browsers in mind, so Ive always tried to use the most up-to-date methods in the examples. Having said that, Ive also tried to acknowledge if something might not work in an older browser, or if a workaround is needed.
Its a long way ahead16 chapters, to be precise. But remember, every ninjas journey starts with a single page (or something like that, anyway). So, turn the page and lets get started!
Who Should Read This Book
This book is suitable for beginner-level web designers and developers. Some knowledge of HTML and CSS is assumed, but no previous programming experience is necessary.
Conventions Used
Youll notice that weve used certain typographic and layout styles throughout this book to signify distinct types of information. Look out for the following items.
Code Samples
Code in this book will be displayed using a fixed-width font, like so:
A Perfect Summer's Day
It was a lovely day for a walk in the park. The birds were singing and the kids were all back at school.
If the code is to be found in the books code archive, the name of the file will appear at the top of the program listing: