Head First JavaScript Programming

( 1 )


What will you learn from this book?

This brain-friendly guide teaches you everything from JavaScript language fundamentals to advanced topics, including objects, functions, and the browser’s document object model. You won’t just be reading—you’ll be playing games, solving puzzles, pondering mysteries, and interacting with JavaScript in ways you never imagined. And you’ll write real code, lots of it, so you can start building your own web ...

See more details below
BN.com price
(Save 26%)$49.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (22) from $24.24   
  • New (15) from $25.92   
  • Used (7) from $24.24   
Head First JavaScript Programming

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
BN.com price
(Save 41%)$42.99 List Price


What will you learn from this book?

This brain-friendly guide teaches you everything from JavaScript language fundamentals to advanced topics, including objects, functions, and the browser’s document object model. You won’t just be reading—you’ll be playing games, solving puzzles, pondering mysteries, and interacting with JavaScript in ways you never imagined. And you’ll write real code, lots of it, so you can start building your own web applications. Prepare to open your mind as you learn (and nail) key topics including:

  • The inner details of JavaScript
  • How JavaScript works with the browser
  • The secrets of JavaScript types
  • Using arrays
  • The power of functions
  • How to work with objects
  • Making use of prototypes
  • Understanding closures
  • Writing and testing applications

What’s so special about this book?

We think your time is too valuable to waste struggling with new concepts. Using the latest research in cognitive science and learning theory to craft a multi-sensory learning experience, Head First JavaScript Programming uses a visually rich format designed for the way your brain works, not a text-heavy approach that puts you to sleep. This book replaces Head First JavaScript, which is now out of print.

Read More Show Less

Product Details

  • ISBN-13: 9781449340131
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 4/10/2014
  • Edition number: 1
  • Pages: 704
  • Sales rank: 153,581

Meet the Author

Eric Freeman is described by Head First series co-creator Kathy Sierra as “one of those rare individuals fluent in the language, practice, and culture of multiple domains from hipster hacker, to corporate VP, engineer, think tank." Professionally, Eric recently ended nearly a decade as a media company executive, having held the position of CTO of Disney Online & Disney.com at The Walt Disney Company. Eric is now devoting his time to WickedlySmart.com and lives with his wife and young daughter on Bainbridge Island. He holds a Ph.D. in Computer Science from Yale University.

Elisabeth Robson is co-founder of Wickedly Smart, an education company devoted to helping customers gain mastery in web technologies. She’s co-author of three bestselling books, Head First Design Patterns, Head First HTML with CSS & XHTML and Head First HTML5 Programming.

Read More Show Less

Table of Contents

Praise for Head First JavaScript Programming;
Praise for other books by Eric T. Freeman and Elisabeth Robson;
Authors of Head First JavaScript Programming;
How to Use This Book: Intro;
Who is this book for?;
We know what you’re thinking.;
Metacognition: thinking about thinking;
Here’s what WE did:;
Here’s what YOU can do to bend your brain into submission;
Read Me;
Tech Reviewers;
AcknowledgmentsThe large number of acknowledgments is because we’re testing the theory that everyone mentioned in a book acknowledgment will buy at least one copy, probably more, what with relatives and everything. If you’d like to be in the acknowledgment of our next book, and you have a large family, write to us.;
Chapter 1: Getting your feet wet;
1.1 The way JavaScript works;
1.2 How you’re going to write JavaScript;
1.3 How to get JavaScript into your page;
1.4 JavaScript, you’ve come a long way baby...;
1.5 How to make a statement;
1.6 Variables and values;
1.7 Back away from that keyboard!;
1.8 Express yourself;
1.9 Doing things more than once;
1.10 How the while loop works;
1.11 Making decisions with JavaScript;
1.12 And, when you need to make LOTS of decisions;
1.13 Reach out and communicate with your user;
1.14 A closer look at console.log;
1.15 Opening the console;
1.16 Coding a Serious JavaScript Application;
1.17 How do I add code to my page? (let me count the ways);
1.18 We’re going to have to separate you two;
Chapter 2: Going further;
2.1 Let’s build a Battleship game;
2.2 Our first attempt...;
2.3 First, a high-level design;
2.4 A few more details...;
2.5 Working through the Pseudocode;
2.6 Oh, before we go any further, don’t forget the HTML!;
2.7 Writing the Simple Battleship code;
2.8 Now let’s write the game logic;
2.9 Step One: setting up the loop, getting some input;
2.10 How prompt works;
2.11 Checking the user’s guess;
2.12 So, do we have a hit?;
2.13 Adding the hit detection code;
2.14 Hey, you sank my battleship!;
2.15 Provide some post-game analysis;
2.16 And that completes the logic!;
2.17 Doing a little Quality Assurance;
2.18 Can we talk about your verbosity...;
2.19 Finishing the Simple Battleship game;
2.20 How to assign random locations;
2.21 The world-famous recipe for generating a random number;
2.22 Back to do a little more QA;
2.23 Congrats on your first true JavaScript program, and a short word about reusing code;
Chapter 3: Getting functional;
3.1 What’s wrong with the code anyway?;
3.2 By the way, did we happen to mention FUNCTIONS?;
3.3 Okay, but how does it actually work?;
3.4 What can you pass to a function?;
3.5 JavaScript is pass-by-value.;
3.6 Weird Functions;
3.7 Functions can return things too;
3.8 Tracing through a function with a return statement;
3.9 Global and local variables;
3.10 Knowing the scope of your local and global variables;
3.11 The short lives of variables;
3.12 Don’t forget to declare your locals!;
Chapter 4: Arrays;
4.1 Can you help Bubbles-R-Us?;
4.2 How to represent multiple values in JavaScript;
4.3 How arrays work;
4.4 How to access an array item;
4.5 Updating a value in the array;
4.6 How big is that array anyway?;
4.7 The Phrase-O-Matic;
4.8 Meanwhile, back at Bubbles-R-Us...;
4.9 How to iterate over an array;
4.10 But wait, there’s a better way to iterate over an array;
4.11 It’s that time again.... Can we talk about your verbosity?;
4.12 Redoing the for loop with the post-increment operator;
4.13 Quick test drive;
4.14 Creating an array from scratch (and adding to it);
4.15 And the winners are...;
4.16 A quick survey of the code...;
4.17 Writing the printAndGetHighScore function;
4.18 Refactoring the code using printAndGetHighScore;
4.19 Putting it all together...;
Chapter 5: A trip to Objectville;
5.1 Did someone say “Objects”?!;
5.2 Thinking about properties...;
5.3 How to create an object;
5.4 What is Object-Oriented Anyway?;
5.5 How properties work;
5.6 How does a variable hold an object? Inquiring minds want to know...;
5.7 Comparing primitives and objects;
5.8 Doing even more with objects...;
5.9 Stepping through pre-qualification;
5.10 Let’s talk a little more about passing objects to functions;
5.11 Oh Behave! Or, how to add behavior to your objects;
5.12 Improving the drive method;
5.13 Why doesn’t the drive method know about the started property?;
5.14 How this works;
5.15 How behavior affects state... Adding some Gas-o-line;
5.16 Now let’s affect the behavior with the state;
5.17 Congrats on your first objects!;
5.18 Guess what? There are objects all around you! (and they’ll make your life easier);
Chapter 6: Getting to know the DOM;
6.1 In our last chapter, we left you with a little challenge. The “crack the code challenge.”;
6.2 So what does the code do?;
6.3 How JavaScript really interacts with your page;
6.4 How to bake your very own DOM;
6.5 A first taste of the DOM;
6.6 Getting an element with getElementById;
6.7 What, exactly, am I getting from the DOM?;
6.8 Finding your inner HTML;
6.9 What happens when you change the DOM;
6.10 A test drive around the planets;
6.11 Don’t even think about running my code until the page is fully loaded!;
6.12 You say “event handler,” I say “callback”;
6.13 How to set an attribute with setAttribute;
6.14 More fun with attributes! (you can GET attributes too);
6.15 So what else is a DOM good for anyway?;
Chapter 7: Serious types;
7.1 The truth is out there...;
7.2 Watch out, you might bump into undefined when you aren’t expecting it...;
7.3 How to use null;
7.4 Dealing with NaN;
7.5 It gets even weirder;
7.6 We have a confession to make;
7.7 Understanding the equality operator (otherwise known as ==);
7.8 How equality converts its operands (sounds more dangerous than it actually is);
7.9 How to get strict with equality;
7.10 Even more type conversions...;
7.11 How to determine if two objects are equal;
7.12 The truthy is out there...;
7.13 What JavaScript considers falsey;
7.14 The Secret Life of Strings;
7.15 How a string can look like a primitive and an object;
7.16 A five-minute tour of string methods (and properties);
7.17 Chair Wars (or How Really Knowing Types Can Change Your Life);
Chapter 8: Building an app;
8.1 This time, let’s build a REAL Battleship game;
8.2 Stepping back... to HTML and CSS;
8.3 Creating the HTML page: the Big Picture;
8.4 Adding some more style;
8.5 Using the hit and miss classes;
8.6 How to design the game;
8.7 Implementing the View;
8.8 How displayMessage works;
8.9 How displayHit and displayMiss work;
8.10 The Model;
8.11 How we’re going to represent the ships;
8.12 Implementing the model object;
8.13 Setting up the fire method;
8.14 Implementing the Controller;
8.15 Processing the player’s guess;
8.16 Planning the code...;
8.17 Implementing parseGuess;
8.18 Counting guesses and firing the shot;
8.19 How to add an event handler to the Fire! button;
8.20 Passing the input to the controller;
8.21 How to place ships;
8.22 Writing the generateShip method;
8.23 Generate the starting location for the new ship;
8.24 Completing the generateShip method;
Chapter 9: Handling events;
9.1 What are events?;
9.2 What’s an event handler?;
9.3 How to create your first event handler;
9.4 Test drive your event;
9.5 Getting your head around events... by creating a game;
9.6 Implementing the game;
9.7 Test drive;
9.8 Let’s add some more images;
9.9 Now we need to assign the same event handler to each image’s onclick property;
9.10 How to reuse the same handler for all the images;
9.11 How the event object works;
9.12 Putting the event object to work;
9.13 Test drive the event object and target;
9.14 Events and queues;
9.15 Even more events;
9.16 How setTimeout works;
9.17 Finishing the image game;
9.18 Test driving the timer;
Chapter 10: Liberated functions;
10.1 The mysterious double life of the function keyword;
10.2 Function declarations versus function expressions;
10.3 Parsing the function declaration;
10.4 What’s next? The browser executes the code;
10.5 Moving on... The conditional;
10.6 How functions are values too;
10.7 Did we mention functions have First Class status in JavaScript?;
10.8 Flying First Class;
10.9 Writing code to process and check passengers;
10.10 Iterating through the passengers;
10.11 Passing a function to a function;
10.12 Returning functions from functions;
10.13 Writing the flight attendant drink order code;
10.14 The flight attendant drink order code: a different approach;
10.15 Taking orders with first class functions;
10.16 Webville Cola;
10.17 How the array sort method works;
10.18 Putting it all together;
10.19 Take sorting for a test drive;
Chapter 11: Serious functions;
11.1 Taking a look at the other side of functions...;
11.2 How to use an anonymous function;
11.3 We need to talk about your verbosity, again;
11.4 When is a function defined? It depends...;
11.5 What just happened? Why wasn’t fly defined?;
11.6 How to nest functions;
11.7 How nesting affects scope;
11.8 A little review of lexical scope;
11.9 Where things get interesting with lexical scope;
11.10 Functions Revisited;
11.11 Calling a function (revisited);
11.12 What the heck is a closure?;
11.13 Closing a function;
11.14 Using closures to implement a magic counter;
11.15 Looking behind the curtain...;
11.16 Creating a closure by passing a function expression as an argument;
11.17 The closure contains the actual environment, not a copy;
11.18 Creating a closure with an event handler;
11.19 How the Click me! closure works;
Chapter 12: Creating objects;
12.1 Creating objects with object literals;
12.2 Using conventions for objects;
12.3 Introducing Object Constructors;
12.4 How to create a Constructor;
12.5 How to use a Constructor;
12.6 How constructors work;
12.7 You can put methods into constructors as well;
12.8 It’s Production Time!;
12.9 Let’s test drive some new cars;
12.10 Don’t count out object literals just yet;
12.11 Rewiring the arguments as an object literal;
12.12 Reworking the Car constructor;
12.13 Understanding Object Instances;
12.14 Even constructed objects can have their own independent properties;
12.15 Real World Constructors;
12.16 The Array object;
12.17 Even more fun with built-in objects;
Chapter 13: Extra strength objects;
13.1 Hey, before we get started, we’ve got a better way to diagram our objects;
13.2 Revisiting object constructors: we’re reusing code, but are we being efficient?;
13.3 Is duplicating methods really a problem?;
13.4 What are prototypes?;
13.5 Inheriting from a prototype;
13.6 How inheritance works;
13.7 Overriding the prototype;
13.8 How to set up the prototype;
13.9 Prototypes are dynamic;
13.10 A more interesting implementation of the sit method;
13.11 One more time: how the sitting property works;
13.12 How to approach the design of the show dogs;
13.13 Setting up a chain of prototypes;
13.14 How inheritance works in a prototype chain;
13.15 Creating the show dog prototype;
13.16 Creating a show dog instance;
13.17 A final cleanup of show dogs;
13.18 Stepping through Dog.call;
13.19 The chain doesn’t end at dog;
13.20 Using inheritance to your advantage... by overriding built-in behavior;
13.21 Using inheritance to your advantage... by extending a built-in object;
13.22 Grand Unified Theory of;
13.23 Better living through objects;
13.24 Putting it all together;
13.25 What’s next?;
Leftovers: The top ten topics (we didn’t cover);
#1 jQuery;
#2 Doing more with the DOM;
#3 The Window Object;
#4 Arguments;
#5 Handling exceptions;
#6 Adding event handlers with addEventListener;
#7 Regular Expressions;
#8 Recursion;
#9 JSON;
#10 Server-side JavaScript;
Read More Show Less

Customer Reviews

Average Rating 5
( 1 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Posted November 7, 2014

    Highly Recommended - for beginners

    Very good book. If anyone is interested to learn javascript , this book would be a great start for them.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)