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
Authors have earned$9,882,857writing, 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
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
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
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Functional Design and Architecture
Alexander GraninSoftware Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
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.
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.
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
I am a Software Engineer and I am in Charge
Alexis Monville and Michael DoyleI am a Software Engineer and I am in Charge is a real-world, practical book that helps you increase your impact and satisfaction at work no matter who you work with.
In the book, we will follow Sandrine, a fictional character who learns to think in a new way enabling her to take a different course of action.
Invest In Digital Health - The Medical Futurist's Guide
Dr. Bertalan MeskoArtificial Intelligence and Digital Health are booming. In this book, we explain why now it's a good time to invest in Digital Health and give recommendations on where to invest by looking at the top 24 technological trends we find the most promising.
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
The Hundred-Page Machine Learning Book
Andriy BurkovEverything you really need to know in Machine Learning in a hundred pages.
Mastering STM32
Carmine NovielloWith more than 600 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the first guide around that introduces the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
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... - #2
The Future of Digital Health
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 and how technology giants such as Amazon or Google want to conquer... - #3
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #4
CCDE Practical Studies (All labs)
3 Books
CCDE lab - #5
"The C++ Standard Library" and "Concurrency with Modern C++"
2 Books
Get my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library... - #6
Modern Management Made Easy
3 Books
Read all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization. - #7
Programming with Ease
3 Books
Alle drei Bände der Serie Programming with Ease in einem Paket. Darin findest du alles, was ich dir zu den wichtigsten Phasen der Softwareentwicklung im Hinblick auf Clean Code Development für langfristig hohe Produktivität sagen kann.Im Band Slicing findest du die Anforderungsanalyse im Rahmen eines iterativ-inkrementellen Vorgehensmodells aus... - #8
Vagrant Ansible
2 Books
Unveil the power of Ansible and Vagrant with this bundle at a special price. You'll have everything you need to get started with Vagrant - learn the basics and how to create your virtual development environments, using Ansible as provisioner! About Vagrant Cookbook Vagrant Cookbook is a complete guide to get started with Vagrant and create your... - #9
Mastering Containers
2 Books
Docker and Kubernetes are taking the world by storm! These books will get you up-to-speed fast! Docker Deep Dive is over 400 pages long, and covers all objectives on the Docker Certified Associate exam.The Kubernetes Book includes everything you need to get up and running with Kubernetes! - #10
Growing Agile: The Complete Coach's Guide
7 Books
Growing Agile: Coach's Guide Series This bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity...