My Cart (0)

Customer Service 1-800-221-5528

Murach’s Modern JavaScript

by Mary Delamater
16 chapters, 608 pages, 242 illustrations
Published March 2024
ISBN 978-1-943873-14-2
Print: $59.50
eBook: $54.50
Print + eBook: $72.00

According to StackOverflow’s 2023 Developer Survey, JavaScript is the most popular language in the world. That’s because JavaScript is used by most websites, from small personal websites to the largest commercial sites.

In the old days, JavaScript was a difficult language to learn due to some quirky features in its early versions. But now, this book can help you learn JavaScript more easily than ever by skipping the confusing old features and jumping straight to the new features and best practices of modern JavaScript. When you finish this book, you’ll have the JavaScript skills that are in such demand today.

College Instructors

Go to our instructor’s site to learn more about this book and its instructor’s materials.

This is my first exposure to Murach's books, and I love them. I like the organization of the content, the consistent approach in each book, and the accuracy of the material."

Bob L., Michigan

  • About this Book
  • Table of Contents
  • FREE Downloads
  • Book FAQs
  • Corrections
  • Reviews

Who this book is for

This book is designed for anyone who wants to learn how to write JavaScript. Today, that includes:

  • Web designers who use HTML and CSS to provide the content and formatting for web pages and want to use JavaScript to add functionality to those pages
  • Server-side programmers who use languages like Python, PHP, Java, or C# and would like to use JavaScript to provide client-side scripting for their web apps

What this book does

To present the JavaScript skills that you need in a manageable progression, this book is divided into three sections. Each section represents a level of expertise that you will achieve.

Section 1: Get started fast

Section 1 presents a seven-chapter course in JavaScript that gets you started fast. Because the pace is adjustable, this section works for those with no prior programming experience as well as for experienced professionals. Beginners can read each chapter carefully and do all the exercises. Professionals can skim over the parts they already know and focus on the differences with other languages. Either way, when you finish this section, you will be able to develop real-world JavaScript apps that script the DOM.

Section 2: Master the essential skills

Section 2 presents the rest of the essential skills that any web developer should have. This includes validating data, saving data in the browser, and working with dates, times, and timers. In addition, this section shows how to use object-oriented programming to organize your code by defining your own objects and by using ES modules.

Section 3: More skills as you need them

When you have time, you can use the chapters in this section to raise your JavaScript skills to a higher level of expertise. This section shows how to:

  • Use Ajax to asynchronously update a part of a web page without reloading the entire page.
  • Use Node.js to run JavaScript on the server, including how to create a web-based API that manages data on a server.
  • Use the HTML <canvas> element to create drawings and animations.

Why you'll learn faster and better with this book

Like all our books, this book is designed to make it as easy as possible for you to learn new skills faster and retain them better. Here are a few of those features:

  • It presents the modern JavaScript skills you’ll definitely need on the job without wasting your time by presenting confusing old features that you aren’t likely to need.
  • The hundreds of short examples quickly show you how a feature works, and the dozens of longer code examples show you how these features work together in a complete app.
  • The exercises at the end of each chapter provide a way for you to gain valuable hands-on experience without any extra busywork.
  • All of the information is presented in paired pages, with the essential syntax, guidelines, and examples on the right page and clear explanations on the left page. This helps you learn faster by reading less.
  • The paired-pages format is ideal for reference when you need to refresh your memory about how to do something.

Recommended software

To develop JavaScript apps, this book recommends that you use the following software. All of this software is available for free. And appendixes A (Windows) and B (macOS) provide complete, step-by-step instructions that you can use to install it on your system.

Visual Studio Code

This popular code editor is free and provides many excellent features for developing JavaScript apps.

Google Chrome

This web browser provides excellent developer tools for debugging JavaScript apps.

Node.js

This runtime environment makes it possible to run JavaScript on a server instead of running it in a web browser.

Related books

HTML and CSS

We recommend our HTML and CSS book as an ideal companion book for our Modern JavaScript book. These two books are designed to work together seamlessly to teach you the HTML, CSS, and JavaScript skills that are actually used on the job.

JavaScript and jQuery

If you need to learn jQuery, we recommend our JavaScript and jQuery book. This book is similar to Modern JavaScript in many ways, but it integrates coverage of jQuery, an influential JavaScript library that has been around since 2006 and is still used extensively in millions of websites.

What people said about Murach's JavaScript and jQuery

“If you are new to web design or an old pro like me, this book is a must-have in my opinion. I love how it starts out with the basics and then moves on to the good stuff. Each chapter is full of examples and sample code showing you how to do the most common techniques that you will face as a web developer/designer.
     “I have not seen a better book on the subject. This one will be on my desk for a while!”
- Web Developer, Colorado

“I just finished a pretty heavy application project, the first serious work I have done with jQuery and Ajax. Along the way, I had to deal with preloading images, manipulations of the DOM, tabs, plugins, and Dialogs…. I kept this book at my side throughout the entire project, and it was indispensable. The answers were right there at every turn. All the examples made sense to me, and they all worked!”
- Alan Vogt, ETL Consultant, Information Builders, Inc.

“What I like about this and other Murach books is that within minutes of opening the book, you are developing hands-on with the technology in question.”
- Charles Zimmerman, Developer

“An essential characteristic of this book, as well as the other Murach books, is that the examples, programs, and applications are all thoroughly tested. This book will work WONDERFULLY to help you build better and more robust websites!”
- Marvin Schneider, Instructor, New York

“I have several books on JavaScript, but the best one is this one. The text, examples, descriptions, and even the layout all bring you, the learner, an ease of use that is missing in other books.”
- Chris Wallace, Denver Visual Studio User Group

View the table of contents for this book in a PDF: Table of Contents (PDF)

Click on any chapter title below to display or hide its content.

Section 1  Get started fast

Chapter 1  How to code and run your first apps

An introduction to web apps and JavaScript

How JavaScript is used for client-side processing

ECMAScript version history

How to use VS Code to work with existing web apps

How to work with folders

How to work with files

How to install the Open in Browser extension

How to run an app

How to use VS Code to develop new web apps

How to create and run an app

How to enter and edit code

How to find and fix syntax errors

The Die Roller app

How to test a web app

How to use a browser to run an app

How to use your browser to find and fix runtime errors

The components of a web app

The HTML

The CSS

The JavaScript

Chapter 2  How to get started with JavaScript

How to get started

An introduction to coding statements

How to code comments

Three primitive data types

How to declare and initialize variables

How to declare and initialize constants

Rules and recommendations for naming variables and constants

How to work with numbers

How to code arithmetic expressions

How to use arithmetic expressions in statements

How to use the console to test expressions and statements

How to display data in the console

How to use the typeof operator

How to fix a precision problem

How to use the Math object

How to work with strings

How to join strings

How to include special characters in strings

How to get input and display output

How to use dialogs

How to parse numbers

Two simple apps

The Miles to Kilometers app

The Test Scores app

Chapter 3  How to code control statements

How to code conditional expressions

How to use the relational operators

How to use the isNaN() function

How to use the logical operators

How to get started with the selection structure

How to code an if statement

How to code a nested if statement

The Guess the Number app

More skills for working with the selection structure

How to use a non-Boolean value in a conditional expression

How to use the conditional operator

How to code a switch statement

The Magic Eight Ball app

How to code the iteration structure

How to code while and do-while loops

How to code for loops

How to use the break and continue statements

The Future Value app

Chapter 4  How to work with arrays and strings

How to get started with arrays

How to create and use an array

How to add, replace, and delete array elements

How to use a for loop with an array

How to use for-in and for-of loops with an array

The Test Scores app

More skills for working with arrays

How to modify or copy an array

How to inspect or transform an array

The Test Scores 2.0 app

More skills for working with strings

How to inspect a string

How to modify a string

How to create an array from a string

How to chain method calls

The Email Check app

The Bio app

Chapter 5  How to code functions and handle events

Three ways to work with functions

How to work with a function declaration

How to work with a function expression

How to work with an arrow function

The Future Value app

More skills for working with functions

How to work with scope

How to work with default parameters

How to work with the rest and spread operators

The Bio app

How to handle events

How to work with events

How to attach events to HTML elements

The Guess the Number app

How to work with the Event object

The Typewriter app

Chapter 6  How to script the DOM

How to get started with DOM scripting

DOM scripting concepts

How to get elements

How to script elements

How to script element attributes

More skills for scripting attributes

How to script the class attribute

The FAQs app

How to script forms and controls

How forms work

How to script text boxes, text areas, and select lists

How to script radio buttons and check boxes

How to use methods and events with forms and controls

The Register app

How to modify the DOM

How to add, replace, and delete nodes

The updated Register app

How to work with images

How to create an image object

How to preload images

The Image Swap app

Chapter 7  How to test and debug an app

An introduction to testing and debugging

The Future Value app

Three types of errors

Common JavaScript errors

How to plan the test runs

How to debug with Chrome’s developer tools

How to find errors

How to set breakpoints

How to step through code

Other debugging techniques

How to trace code execution

More methods for tracing execution

How to view the HTML and CSS for a web page

Section 2  Master the essential skills

Chapter 8  How to work with dates, times, and timers

How to work with dates and times

How to create Date objects

How to use the methods of a Date object

How to format dates

How to perform calculations on dates

The Countdown app

How to work with timers

How to use a one-time timer

How to use an interval timer

The Clock app

The Timer app

The Slide Show app

Chapter 9  How to work with data validation and exceptions

How to use HTML data validation

How to use input controls for data validation

How to use attributes for data validation

An introduction to regular expressions

The Register app

How to customize HTML validation

How to validate an element or a form

How to create custom validation

The Register app 2.0

How to work with exceptions

How to use try-catch statements

How to create and throw exceptions

The Future Value app

Chapter 10  How to work with web storage

An introduction to cookies and web storage

An introduction to cookies

How cookies compare to web storage

How to get started with web storage

How to work with local storage

How to work with session storage

How to use the nullish coalescing operator

The Future Value app

More skills for working with web storage

How to convert an object to JSON and back

How to use Chrome to work with stored items

The Task List app

Chapter 11  More skills for working with arrays

More methods of an array

How to inspect an array

How to sort elements

How to work with each element in an array

How to filter, map, and reduce elements

The Test Scores app

Advanced skills for working with arrays

How to destructure an array

How to create and use an array of arrays

How to loop through an array of arrays

How to sort an array of arrays

How to flatten an array of arrays

The Task List app

How to copy an array

How to make a shallow copy

How to make a deep copy

Chapter 12  How to work with objects

How to get started with objects

How to use an object literal to define an object

How to use a class to define an object

How to work with objects

How to create and use JavaScript libraries

The Invoice app

How to work with encapsulation

How to work with private properties and methods

How to work with accessor properties

How to work with inheritance and object composition

How to work with inheritance

When to use inheritance

When to use object composition

The Trips app

More skills for working with objects

How to create cascading methods

How to work with static properties and methods

How to nest objects

How to destructure an object

How to work with generator functions

The Task List app

Chapter 13  How to work with modules

How to work with ES modules

How to export and import module items

How to declare a script as a module

The Slide Show app

More skills for working with modules

How to rename exports and imports

How to export and import classes

How to create a default export

How to work with import maps

The Task List app

The Clock app

Legacy skills for working with modules

How closures work

The module pattern

Section 3  More skills as you need them

Chapter 14  How to work with Ajax

Introduction to Ajax

How Ajax works

Two common data formats for Ajax

How to make an Ajax request

The JSON Placeholder API

How to use the Fetch API for GET requests

How to use the Fetch API for POST, PUT, and DELETE requests

How to use the async and await keywords

The Astronomy Picture of the Day app

How to use asynchronous code in a module

How to export an asynchronous function

How to use a top-level await

The User Directory app

How to make cross-origin requests

Chapter 15  How to work with Node.js

How to use the node command

How to interactively test code

How to run a script

How to pass arguments to a script

How to work with Node.js modules

How to use ES and CommonJS modules

How to use the built-in file system module with promises

How to create and use your own module

How to work with NPM modules

How to install NPM modules

How package.json files work

How to use Express to create a web-based API

How to start an Express app for an API

How to set up a route for a GET request

How to set up routes for POST, PUT, and DELETE requests

The Email List API

The CORS Proxy API

Chapter 16  How to work with drawing and animation

An introduction to the Canvas API

How the Canvas API works

How to provide for accessibility

How to draw rectangles and text

How to draw rectangles

How to draw text

The Tic Tac Toe app

How to draw lines

How to work with paths

The Drawing app

How to draw circles and colors

How to draw circles and arcs

How to draw colors

The Smiley Face app

How to create animations

How to use the requestAnimationFrame() method

The Pong app

How to work with the HTML Drag and Drop API

How to drag and drop an HTML element

The Movie List app

Resources

Appendix A  How to set up Windows for this book

How to download the files for this book

How to install Chrome

How to install Visual Studio Code

How to install Node.js and the http-server module

How to test an app on a local web server

Appendix B  How to set up macOS for this book

How to download the files for this book

How to install Chrome

How to install Visual Studio Code

How to install Node.js and the http-server module

How to test an app on a local web server

Sample PDFs

See for yourself how this book can get you started fast with JavaScript development.

Appendix A: How to set up Windows for this book

This appendix shows how to set up Windows for JavaScript development, including instructions for installing the required software and downloading the files for the book examples and exercises. When you’re done, you’ll be able to work through the examples and exercises presented in this book.
Download Now

Appendix B: How to set up macOS for this book

This appendix shows how to set up macOS for JavaScript development, including instructions for installing the required software and downloading the files for the book examples and exercises. When you’re done, you’ll be able to work through the examples and exercises presented in this book.
Download Now

Chapter 1: How to code and run your first apps

This chapter begins with the background concepts, terms, and skills you need to start using JavaScript to provide the functionality for a web page. Then, it presents a quick tutorial on using the popular Visual Studio Code editor to develop your first JavaScript apps. Finally, it shows the code for a JavaScript app that validates data the user enters on a web page.
Download Now

Chapter 2: How to get started with JavaScript

The goal of this chapter is to get you off to a good start with the JavaScript language, especially if you’re new to programming. If you have experience with another language, you can decide how rapidly you move through this chapter. Otherwise, you can read slowly and carefully, test the code as you go, and do each of the exercises at the end of this chapter to be sure you understand the material before moving on.
Download Now

Book apps and exercises

This download includes:

  • The complete code for all of the apps presented in this book.
  • The starting code for the exercises presented at the end of each chapter.
  • The solutions to those exercises.

Appendixes A (Windows) and B (macOS) show how to install and use these files.
Download Now

On this page, we’ll be posting answers to the questions that come up most often about this book. So if you have any questions that you haven’t found answered here at our site, please email us. Thank you!

There are no book corrections that we know of at this time. But if you find any, please email us, and we’ll post any corrections that affect the technical accuracy of the book here. Thank you!

There are no reviews for this product yet.

To leave a review, please log in to your account.     Log In Here

Our Ironclad Guarantee

You must be satisfied. Try our print books for 30 days or our eBooks for 14 days. If they aren't the best you've ever used, you can return the books or cancel the eBooks for a prompt refund. No questions asked!

Contact Murach Books

For orders and customer service:

1-800-221-5528

Weekdays, 8 to 4 Pacific Time

College Instructors

If you're a college instructor who would like to consider a book for a course, please visit our website for instructors to learn how to get a complimentary review copy and the full set of instructional materials.