Customer Service 1-800-221-5528

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

Today, JavaScript is used on most of the pages of a modern, commercial website. That’s why every web developer should know how to use JavaScript. The problem is that JavaScript is surprisingly difficult to learn, not only for programming novices but also for those with programming experience. Now, at last, Murach’s JavaScript uses a new approach that works for students with no programming background as well as for students who have taken programming courses.

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

Murach’s jQuery is designed as an extension to our JavaScript book. As a result, it will work seamlessly with Murach’s JavaScript in two-course progression from JavaScript to jQuery. Or, it can be combined with our JavaScript book in a condensed JavaScript and jQuery course for advanced students.

Similarly, Murach’s HTML5 and CSS3 is designed for a Web Design or Web Development course. And it is designed to work seamlessly in a three-course progression from HTML5 and CSS3 to JavaScript to jQuery. If you use all three of our books for these courses, you can be sure your students will have the skills they need 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 software your students need

To develop JavaScript applications, your students need:

  • any text editor (this book recommends Aptana Studio 3, which is available for free)
  • 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. That’s why we recommend Aptana Studio 3. It’s available for free, it can be used for entering JavaScript code (as well as HTML and CSS code), and it runs on both Windows and Mac OS.

To test a web page, your students can use their default browsers. But we recommend that they also test their pages in Chrome, which includes terrific developer tools. Again, these browsers are available for free.

To help your students install these products on their own systems, Appendix A provides the procedures that they’ll need. In addition, chapter 1 presents a short tutorial on using Aptana, 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

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. 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