Customer Service 1-800-221-5528

JavaScript Programming Book - Murach

Murach’s JavaScript (2nd Edition)

by Mary Delamater
17 chapters, 630 pages, 259 illustrations
Published September 2015
ISBN 978-1-890774-85-1
List price: $54.50

If you want to teach an intense course on JavaScript with just an introductory chapter on jQuery, this is the right book. For most JavaScript courses, though, we recommend our JavaScript and jQuery book.

That’s because every web developer today should know how to use JavaScript for what it does best and jQuery for what it does best. That’s what the latest edition of Murach’s JavaScript and jQuery shows your students how to do. We think that’s the right didactic approach for most JavaScript courses, and ours is the only book that takes that approach.

Buy this book

You are currently on the Murach site for instructors. To buy this book, please visit our retail site.

I bought this book to fill in the massive hole a Deitel book leaves in a college course. The two-page topic style is great. Others have commented on the Pros of this book in depth so I will only add that I have found no cons to date. I am looking into other Murach titles!"

Posted at an online bookseller

  • About this Book
  • Table of Contents
  • Courseware
  • FAQs
  • Corrections

Book description

To present the JavaScript skills that you need today in a manageable progression, this book is divided into three sections, representing the three levels of expertise that your students will achieve with this book.

Section 1: Get your students off to a great start

  • Section 1 of this book presents a six-chapter course in JavaScript that gets your students off to a great start. This section works for programming beginners as well as students with some programming experience because the pace is adjustable. Beginners can move through the material slowly and do all the exercises. Students with some programming experience can move more quickly and do just the exercises that you assign.
  • Either way, when they finish this section, your students will be able to develop real-world JavaScript applications of their own. This will put your course far ahead of what you can accomplish with competing books.

Section 2: Make sure they master the JavaScript essentials

  • Section 2 presents the essential JavaScript skills that every web developer should have. The six chapters in this section not only expand upon what your students have learned in section 1, but they also present new skills, like how to use arrays, web storage, and JavaScript libraries...how to create object-oriented JavaScript applications... how to handle exceptions...and how to use regular expressions.
  • For some courses, this may be as far as you need to go because sections 1 and 2 are a solid JavaScript course by themselves.

Section 3: Take your students to the expert level

  • If you have the time and your students are ready for it, section 3 presents the advanced skills that will take them to the expert level. This includes skills like how to work with events, images, and timers as they build applications like image rollovers and slide shows...how to use closures, callbacks, namespaces, and the module pattern to make applications bulletproof...and how to use JSON to transmit and store data. This section finishes with an introduction to jQuery that shows your students how jQuery can be used for the DOM scripting in JavaScript applications so the code is easier to read, debug, and maintain.

What courses this book can be used for

From the start, we designed this book with both beginning and advanced students in mind. We also wanted to include all of the skills that a professional JavaScript programmer needs on the job. A tall order, for sure, but that’s why this book can be used for:

  • a beginning JavaScript course
  • an advanced JavaScript course
  • a two-semester JavaScript course

Related books for related courses

If your JavaScript course includes jQuery instead of being a pure JavaScript course, we have a newer book that will probably be a better fit for you: Murach’s JavaScript and jQuery (4th Edition). The first section covers JavaScript essentials, the second covers jQuery essentials, and the third covers advanced JavaScript features that you may want to teach if you have time. You can take a look at the table of contents to see whether this is the edition that’s right for your curriculum.

And if you offer an HTML and CSS course in your program, please consider our HTML5 and CSS3 book. It’s designed to work seamlessly with any of our JavaScript and jQuery texts in a two- or three-course sequence. It uses our unique teaching methods so your students will learn more in less time. And it’s the only book that ensures that your students will learn the HTML and CSS skills that are actually used on the job.

What's new in this edition

The first edition of this book was published in 2009, and it quickly developed a following. However, a lot has changed since then. In particular, jQuery is now used by 60% of the one million most-visited websites, and it no longer makes sense to use JavaScript for the type of DOM scripting that jQuery is designed for.

For that reason, the new edition has dropped the section 3 focus on DOM scripting. Instead, all three sections focus on just the JavaScript skills that professionals need on the job. But that includes advanced skills like how to use closures, callbacks, namespaces, and the module pattern to build bulletproof applications.

Beyond that, some instructors thought that the first edition was too difficult for programming beginners, and we agreed. For that reason, section 1 has been completely rewritten so it works for both beginners and experienced programmers.

So, for those of you who used the first edition in your courses, the short answer to “What’s new?” is “Just about everything.” In section 2, you may recognize some of the best features of that section in the first edition, but even that has been improved with more examples and more complete applications. As we see it, if you liked the first edition at all, you’re going to find that this 2nd Edition is a dramatic improvement...in every way.

What's new with ECMAScript 2015 and 2016

Because this book was published in 2015, it doesn’t present all of the new features that are in the ECMAScript 2015 and 2016 specifications. If you want to include some of those features in your course, however, we offer a FREE PDF download called “What’s new with ECMAScript 2015 and 2016” that presents all of those features plus the Internationalization API. This PDF is both tutorial and reference, and it makes it easy for your students to add the new skills to their skillsets.

Your students can access this download by going to the FREE Downloads tab on the book page on our retail site. And you can download this PDF right now.

What software your students need

To develop JavaScript applications, your students need:

  • any text editor
  • Google Chrome along with the default browser: Internet Explorer for Windows users and Safari for Mac OS users

Although your students can use any text editor with this book, a text editor that includes syntax coloring and auto-formatting will help them develop applications more quickly and with fewer errors. In the book, we recommend Aptana Studio 3; however, it’s no longer supported and has become hard to install. 

So now, we recommend Brackets. It’s available for free, it can be used for entering JavaScript and jQuery code (as well as HTML and CSS code), and it runs on Windows, Mac OS, and Linux systems. To help your students get started with installing and using Brackets, we’ve created a Brackets tutorial that you can use in place of the Aptana material in the book. You can distribute this to your students or have them download it from the book page at our retail website.

To test a web page, your students can use the default browser on their systems. But we recommend that they also test their pages in Chrome, which includes a terrific set of developer tools. Appendix A provides a procedure for installing Chrome, and chapter 6 shows how to use Chrome for debugging.

What people say about this book

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

“There are a plethora of source code examples that are introduced and improved as new concepts are introduced. An excellent resource for newbies and experienced developers.”
- Mike Redlich, ACGNJ Java Users Group

“This book more clearly teaches JavaScript than any other book that I have seen.
     “One of its strengths is the examples it uses to teach JavaScript. It contains complete examples of HTML, CSS, and JavaScript code. In those example codes, the authors clearly highlight which elements are referenced in the different parts of the JavaScript. This book allows the reader to develop a clearer understanding of how each JavaScript component works without ambiguity.”
- Eric Mortensen, Northeast Ohio Oracle Users Group

“This book employs the paired-pages format that Murach is known for: For each topic the right page contains a figure with example code, diagrams, tables and bullet points, and the left page contains the explanatory text. I like this format a lot because it keeps the book well-organized and makes it easy to refer back to….
     “The paired-pages format and the end-of-chapter exercises are the main reasons why I use and recommend Murach books for people looking to learn a new technology.”
- Bruce Alspaugh, St. Louis Java Users Group

“Comparing Murach's Javascript to the six or seven other Javascript books I've bought in the past three years, I think it has the best blend of practicality, coverage, and clarity.”
- Posted at Amazon

To view the table of contents for this book in a PDF, just click on the link below:

Table of Contents

Section 1 Get off to a fast start with JavaScript

Chapter 1 Introduction to web development

How a web application works

The components of a web application

How static web pages are processed

How dynamic web pages are processed

How JavaScript is used for client-side processing

What you need to know about the ECMAScript specification

The components of a JavaScript application

The HTML

The CSS

The JavaScript

The HTML skills that you need for this book

How to use the HTML5 semantic elements

How to use the div and span elements

How to use the basic HTML attributes

The CSS skills that you need for this book

How to provide the CSS styles for an HTML page

How to code the basic CSS selectors

How to code CSS rule sets

How to test a JavaScript application

How to run a JavaScript application

How to find errors in your code

How to provide cross-browser compatibility

How to use Aptana to develop JavaScript applications

How to create or import a project

How to work with files

How to edit a file

How to run a JavaScript application

Chapter 2 Getting started with JavaScript

How to include JavaScript in an HTML document

Two ways to include JavaScript in the head of an HTML document

How to include JavaScript in the body of an HTML document

The JavaScript syntax

How to code JavaScript statements

How to create identifiers

How to use comments

How to use objects, methods, and properties

How to use the write and writeln methods of the document object

How to work with JavaScript data

The primitive data types

How to code numeric expressions

How to work with numeric variables

How to work with string and Boolean variables

How to use the parseInt and parseFloat methods

Two illustrative applications

The Miles Per Gallon application

The Test Scores application

Chapter 3 The essential JavaScript statements

How to code the basic control statements

How to code conditional expressions

How to code if statements

How to code while and do-while loops

How to code for loops

Three illustrative applications

The enhanced Miles Per Gallon application

The Future Value application

The enhanced Test Scores application

How to work with arrays

How to create and use arrays

How to use for loops to work with arrays

The Test Scores application with an array

The user interface

The JavaScript

Chapter 4 How to work with JavaScript objects, functions, and events

How to use objects to work with data

How to use the window and document objects

How to use Textbox and Number objects

How to use Date and String objects

How to use the DOM to change the text for an element

How to use functions

How to create and call a function expression

How to create and call a function declaration

When and how to use local and global variables

When and how to use strict mode

How to handle events

How to attach an event handler to an event

How to use an onload event handler to attach other event handlers

Two illustrative applications

The Miles Per Gallon application

The Email List application

Chapter 5 How to script forms and controls

DOM scripting properties and methods

DOM scripting concepts

The properties of the Node interface

The methods of the Document and Element interfaces

The properties of the DOM HTML specification

The FAQs application

The HTML and CSS

The JavaScript

How to script forms and controls

How forms work

How to script Textbox, Textarea, and Select objects

How to script Radio and Checkbox objects

How to use the methods and events for forms and controls

The Register application

The HTML and CSS

The JavaScript

How to add new nodes to the DOM

How to create nodes and add them to the DOM

How to add rows and cells to a DOM table

The Register application with a table

The HTML and CSS

The JavaScript

Chapter 6 How to test and debug a JavaScript application

An introduction to testing and debugging

Typical test phases for a JavaScript application

The three types of errors that can occur

Common JavaScript errors

How top-down coding and testing can simplify debugging

How to debug with Chrome’s developer tools

How to use Chrome to find errors

How to use breakpoints and step through your code

Other debugging methods

How to debug in Internet Explorer

How to trace the execution of your JavaScript code

How to view the source code

When and how to validate the HTML

Section 2 JavaScript essentials

Chapter 7  How to work with numbers, strings, and dates

How to work with numbers

How to use the properties and methods of the Number object

How to use the methods of the Math object

How to generate a random number

The PIG application

The HTML

The JavaScript

How to work with strings

How to use escape sequences in strings

How to use the methods of the String object

Examples of working with strings

How to work with dates and times

How to create Date objects

The methods of the Date object

Examples of working with dates

The Count Down application

The HTML and CSS

The JavaScript

Chapter 8  How to code control statements

How to code conditional expressions

How to use the equality and identity operators

How to use the relational operators

How to use the logical operators

How to code the selection structures

How to code if statements

How to code switch statements

How to use the conditional operator

How to use the AND and OR operators for selections

The Invoice application

The HTML

The JavaScript

How to code the iteration structures

How to code while and do-while loops

How to code for loops

How to use the break and continue statements

Chapter 9 How to work with arrays and web storage

How to create and use an array

How to create an array

How to add and delete array elements

How to use for loops to work with arrays

How to use for-in loops to work with arrays

How to use the methods of an Array object

The methods of an Array object

Examples of the Array methods

The ECMAScript 5 methods

Examples of the ECMAScript 5 methods

Other skills for working with arrays

How to use a String method to create an array

How to create and use an associative array

How to create and use an array of arrays

How to use web storage

How to use local and session storage

How to use Chrome to view and edit items in web storage

The Task Manager application

The HTML and CSS

The JavaScript

The JavaScript with an ECMAScript 5 enhancement

Chapter 10 How to create and use functions

Basic skills for working with functions

How to create and call a function

How values are passed to functions

How lexical scope works

How to create and use JavaScript libraries

The Task Manager application

The HTML and CSS

The storage library

The task list library

The main JavaScript file

Object-oriented skills for working with functions

How to use the arguments property of a function

How to use the this keyword and the call and apply methods

How to use the bind method to set the this keyword

Chapter 11 How to create and use objects

Basic skills for working with objects

How to create and use the native object types

How to create your own objects with object literals

How to extend, modify, or delete an object

How to create your own object types with constructor functions

What you need to know about JavaScript prototypes

How prototypes work

When and how to create custom prototypes

How to use the create method of the Object object

The Task Manager application

The HTML and CSS

The storage library

The task library

The task list library

The main JavaScript file

Advanced skills for working with objects

How to inherit methods from another object with Object.create methods

How to inherit methods from another object with constructors

How to add methods to the native object types

How to create cascading methods

How to use the in, instanceof, and typeof operators

The enhanced Task Manager application

The new native objects library

The change to the task library

The enhanced storage library

The enhanced task list library

The enhanced main JavaScript file

Chapter 12 How to use regular expressions, handle exceptions, and validate data

How to use regular expressions

How to create and use regular expressions

How to create regular expression patterns

How to use the global and multiline flags

String methods that use regular expressions

Regular expressions for data validation

How to handle exceptions

How to create and throw Error objects

How to use the try-catch statement to handle exceptions

The Register application

The user interface

The HTML and CSS

The navigate and fields libraries

The validate library

The validate_form library

The main JavaScript code

Section 3 Advanced JavaScript skills

Chapter 13 How to work with events, images, and timers

How to work with events

An overview of event types

How to attach and detach event handlers

How to cancel the default action of an event

The FAQs application

The user interface

The event library

The main JavaScript file

How to work with images

How to create image rollovers

How to preload images

The Rollover application

The HTML

The main JavaScript file

How to use timers

How to use a one-time timer

How to use an interval timer

The Slide Show application

The HTML

The slideshow library

The main JavaScript file

Chapter 14 How to work with closures, callbacks, and recursion

Introduction to closures

How the scope chain works

How closures work

Closures in the Rollover application

How to use closures

How to use closures to create private state

How to code an immediately invoked function expression (IIFE)

How to use an IIFE to create block scope

How to solve the closure loop problem

How to work with the this keyword in closures

The Slide Show application

The HTML

The slide show library

The main JavaScript file

How to use callbacks

How callback functions work

How to create and use callback functions

How to work with the this keyword in callback functions

How to use recursion

How recursion works

How to code and use a binary search recursive function

The Task Manager application

The HTML

The storage library file

The task list library file

The main JavaScript file

Chapter 15 How to work with namespaces, modules, and custom properties

How to work with namespaces

The global namespace pollution problem

How to create and use namespaces

How to create nested namespaces and use aliases

How to prevent global pollution with an IIFE

The Task Manager application

The namespace library

The storage library

The task list library

The main JavaScript file

How to work with the module pattern

What the module pattern is

How to augment a module

The Slide Show application

The HTML

The slide show library

The slide show enhancements library

The main JavaScript file

How to customize properties

The attributes of an object property

How to enumerate an object’s properties

The defineProperty method of the Object object

How to use the defineProperty method

How to use the defineProperties and create methods of the Object object

How to inspect property attributes

The enhanced Slide Show application

The slide show library

The slide show enhancements library

The main JavaScript file

Chapter 16 How to work with JavaScript Object Notation (JSON)

An introduction to JSON

What data serialization and deserialization are

How data formats work

What JavaScript Object Notation (JSON) is

How to work with JSON in JavaScript

An introduction to the global JSON object

How to use the stringify method of the JSON object

How to use the parse method of the JSON object

The Task Manager application

The HTML

The JSON string in local storage

The main JavaScript file

How to customize the stringify method

How to use the toJSON method

How to use a toJSON method to customize the Task Manager application

How to use the replacer parameter of the stringify method

How to use the space parameter of the stringify method

The serialization order of the stringify method

How to customize the parse method

How to use the reviver parameter of the parse method

Some problems with checking if a string is a date

The enhanced Task Manager application

The JSON string in local storage

The storage library

The main JavaScript file

Chapter 17 When and how to use jQuery

Introduction to jQuery

What jQuery is

When to use jQuery

How to include jQuery in a web page

How to code jQuery selectors, methods, and event methods

Some common jQuery selectors, methods, and event methods

How to use jQuery to simplify the FAQs application

The Email List application in jQuery

The HTML

The jQuery

Introduction to jQuery UI

What jQuery UI is

How to include jQuery UI in a web page

How to use any jQuery UI widget

How to use the Accordion widget to implement the FAQs application

Introduction to jQuery plugins

How to find jQuery plugins

How to use any jQuery plugin

How to use the bxSlider plugin for carousels

How to create your own plugins

The structure of a plugin

How to code a plugin that highlights the items in a menu

How to add options to a plugin

If you aren’t already familiar with the supporting courseware that we provide for a book, please go to About our Courseware. As you will see, our courseware consists of the end-of-chapter activities in the book, the files in the student download at our retail site, and the instructor’s materials. These components provide everything that other publishers provide in a way that delivers better results.

If you are familiar with our courseware, here’s a quick summary of the courseware for this book. For a detailed description in PDF format, please read the Instructor’s Summary.

End-of-chapter activities in the book

  • Term lists
  • Chapter summaries
  • Practice exercises

Student download at our retail site

  • HTML, CSS, and JavaScript source code for all the applications that are presented in the book
  • Starting source code for the exercises in the book
  • Solutions to the book exercises

Appendix A in the book gives your students complete instructions for downloading and installing these items on a PC or Mac.

Instructor’s materials

  • Instructional objectives by chapter
  • PowerPoint slides for classroom presentations
  • Test banks in multiple formats
  • Extra chapter exercises that aren’t in the book, plus their solutions
  • Short exercises that aren’t in the book that can be used for added practice, quizzes, or tests, plus their solutions
  • The files that students can download at our retail site: (1) the book applications, (2) starting points for the exercises in the book, and (3) solutions to the exercises in the book

To view the "Frequently Asked Questions" for this book in a PDF, just click on this link: View the questions

Then, if you have any questions that aren't answered here, please email us. Thanks!

To view the corrections for this book in a PDF, just click on this link: View the corrections

Then, if you find any other errors, please email us so we can correct them in the next printing of the book. Thank you!

Murach college books and courseware since 1974