The JavaScript Way
The JavaScript Way
A gentle introduction to an essential language
About the Book
Love it or hate it, JavaScript is avidly eating the world of software development. From web sites and apps to servers, smartphones and connected objects, JavaScript is everywhere. It has evolved from a niche scripting tool crafted in a few days into a modern, multi-purpose language sitting on top of a rich ecosystem and a vibrant developer community. Some even consider JavaScript to be the most important technology in software development nowadays.
However, learning JavaScript properly is not that easy. Many resources are outdated and teach obsolete practices. Many others cover advanced topics that are of little interest to beginners and "switchers" coming from other languages and platforms.
This book aims to be a useful companion for anyone wishing to (re)discover the many facets of JavaScript. Numerous brain cycles were spent to make it:
- Beginner-friendly yet comprehensive. From the very basics of programming up to full-stack web development, a lot of topics are covered in a simple and accessible way. No prior knowledge needed!
- Standards-aligned. This book is entirely written using the recent ES2015 syntax, giving you future-proof knowledge. From start to finish, it enforces good programming habits, embraces the ubiquitous JavaScript tools ESLint and Prettier and closely follows the popular AirBnb Style Guide.
- Hands-on. No real learning happens without practicing! Each chapter is accompanied by a series of exercises to put your newly acquired skills into action. A three-part project will guide you in the creation of a social news web application (see it in action).
- Easy to follow. Code along directly in your browser or build yourself a great JavaScript development environment.
About the Contributors
Teacher @ OpenClassrooms
Initial English translation and many good ideas.
Editor @ OpenClassrooms
Initial proofreading and many good ideas.
Reader Testimonials

Dmitri Grabov
Founder and JavaScript instructor at Constructor Labs
The best entry level JS book out there
Ahmed Alharbi
Multidisciplinary freelance developer
There's literally no other book that helped me like yours did in my school, work and ultimately in my life and career, I’m literally writing apps now. Your way of saying things is just on point.

Sasha Argunov
If you are searching for a solid understanding of the language with a lot of examples and exercises, that's the book for you. I was actually surprised by how good the book was. It's so far my favourite.
Table of Contents
-
Introduction
-
About this book
- Who this book is for
- Overview
- Following along
-
Welcome to programming
- TL;DR
- What’s a program?
- How do you create programs?
- Learn to code
-
Introducing JavaScript
- TL;DR
- History of JavaScript
- JavaScript: an essential language
- Version used in this book
-
Environment setup
- Prerequisite: a modern browser
- Solution A: coding online
- Solution B: building a local development environment
-
About this book
-
I Learn to code programs
-
1. 3, 2, 1… Code!
- TL;DR
- Your first program
- Values and types
- Program structure
- Coding time!
-
2. Play with variables
- TL;DR
- Variables
- Expressions
- Type conversions
- User interactions
- Variable naming
- Coding time!
-
3. Add conditions
- TL;DR
- What’s a condition?
- Alternative conditions
- Add additional logic
- Multiple choices
- Coding time!
-
4. Repeat statements
- TL;DR
- Introduction
-
The
while
loop -
The
for
loop - Common mistakes
- Which loop should I use?
- Coding time!
-
5. Write functions
- TL;DR
- Introduction: the role of functions
- Discovering functions
- Function contents
- Anonymous functions
- Guidelines for programming with functions
- Coding time!
-
6. Create your first objects
- TL;DR
- Introduction
- JavaScript and objects
- Programming with objects
- JavaScript predefined objects
- Coding time!
-
7. Store data in arrays
- TL;DR
- Introduction to arrays
- Manipulating arrays in JavaScript
- Iterating over an array
- Updating an array’s content
- Coding time!
-
8. Work with strings
- TL;DR
- String recap
- Obtaining string length
- Converting string case
- Comparing two strings
- Strings as sets of characters
- Turning a string into an array
- Searching inside a string
- Breaking a string into parts
- Coding time!
-
9. Understand object-oriented programming
- TL;DR
- Context: a multiplayer RPG
- JavaScript classes
- Under the hood: objects and prototypes
- Object-oriented programming
- Coding time!
-
10. Discover functional programming
- TL;DR
- Context: a movie list
- Program state
- Pure functions
- Array operations
- Higher-order functions
- JavaScript: a multi-paradigm language
- Coding time!
-
11. Project: a social news program
- Objective
- Functional requirements
- Technical requirements
- Expected result
-
1. 3, 2, 1… Code!
-
II Create interactive web pages
-
12. What’s a web page?
- TL;DR
- Internet and the Web
- The languages of the Web
- Developing web pages
- Coding time!
-
13. Discover the DOM
- TL;DR
- Introduction to the DOM
- Web page structure
- Get started with the DOM in JavaScript
- Coding time!
-
14. Traverse the DOM
- TL;DR
- Sample web page
- Selecting elements
- Obtaining information about elements
- Coding time!
-
15. Modify page structure
- TL;DR
- Modify an existing element
- Adding a new element
- Variations on adding elements
- Replacing or removing nodes
- Styling elements
- DOM manipulations and performance
- Coding time!
-
16. React to events
- TL;DR
- Introduction to events
- The event family
- Reacting to common events
- Go farther with events
- Coding time!
-
17. Manipulate forms
- TL;DR
- JavaScript and forms
- Form fields
- Forms as DOM elements
- Form validation
- Coding time!
-
18. Animate elements
- TL;DR
- Repeat an action at regular intervals
- Trigger an action after a delay
- Animate page elements
- Choosing the right animation technique
- Coding time!
-
19. Project: a social news web page
- Objective
- Functional requirements
- Technical requirements
- Starter code
- Expected result
-
12. What’s a web page?
-
III Build web applications
-
20. Web development 101
- TL;DR
- How the Web works
- HTTP, the web protocol
- From web sites to web apps
- JSON, a data format for the web
-
21. Query a web server
- TL;DR
- Creating asynchronous HTTP requests in JavaScript
- Handling JSON data
- Coding time!
-
22. Use web APIs
- TL;DR
- Introducing web APIs
- Consuming a web API
- Web APIs and authentication
- Coding time!
-
23. Send data to a web server
- TL;DR
- Sending data: the basics
- Sending form data
- Sending JSON data
- Coding time!
-
24. Discover Node.js
- TL;DR
- Introducing Node.js
- Node.js modules
- Node.js packages
- Package management with npm
- Coding time!
-
25. Create a web server
- TL;DR
- Using a framework
- Responding to requests
- Creating an API
- Exposing data
- Accepting data
- Publishing web pages
- Coding time!
-
20. Web development 101
-
Conclusion
-
Summary and perspectives
- TL;DR
- The road ahead
- Acknowledgments
-
Summary and perspectives
-
Appendices
-
Style guide
- Naming
- Code formatting
- Code quality
-
Style guide
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Do Well. Do Good.
Authors have earned$11,721,492writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
Recipes for Decoupling
Matthias NobackWrite software that survives
CQRS by Example
Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary- Leverage your Software Architecture skills by learning everything about CQRS in detail with lots of examples
- Develop faster applications by applying CQRS and fostering Read Models and Projections
- Learn how to apply CQRS into a brownfield project from a pragmatic approach
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Maîtriser Apache JMeter
Philippe Mouawad, Bruno Demion (Milamber), and Antonio Gomes RodriguesToute la puissance d'Apache JMeter expliquée par ses commiteurs et utilisateurs experts. De l'intégration continue en passant par le Cloud, vous découvrirez comment intégrer JMeter à vos processus "Agile" et Devops.
If you're looking for the newer english version of this book, go to Master JMeter : From load testing to DevOps
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Introduction to Data Science
Rafael A IrizarryThe demand for skilled data science practitioners in industry, academia, and government is rapidly growing. This book introduces concepts from probability, statistical inference, linear regression and machine learning and R programming skills. Throughout the book we demonstrate how these can help you tackle real-world data analysis challenges.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
Top Bundles
- #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #4
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #8
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon... - #10
Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!?