Home > Store

Learn Enough JavaScript to Be Dangerous: Write Programs, Publish Packages, and Develop Interactive Websites with JavaScript (LiveLessons)

Learn Enough JavaScript to Be Dangerous: Write Programs, Publish Packages, and Develop Interactive Websites with JavaScript (LiveLessons)

Your browser doesn't support playback of this video. Please download the file to view it.

Online Video

Register your product to gain access to bonus material or receive a coupon.

Description

  • Copyright 2022
  • Edition: 1st
  • Online Video
  • ISBN-10: 0-13-784358-5
  • ISBN-13: 978-0-13-784358-9

7+ Hours of Video Instruction

In Learn Enough JavaScript to Be Dangerous: Write Programs, Publish Packages, and Develop Interactive Websites with JavaScript, renowned instructor Michael Hartl teaches the concepts, skills, and approaches you need to be professionally productive with JavaScript for both interactive websites and for general-purpose programming.

Overview

JavaScript is the programming language of the World Wide Web, and it is also developing into a powerful general-purpose programming language. You'll love the way this series teaches programming with JavaScript, where you don't need to learn "everything" about it--just how to use it efficiently to solve real problems. Best-selling author Michael Hartl teaches JavaScript by getting you started writing practical and modern JavaScript programs as fast as possible, with a focus on the real tools used every day by software developers.

Even if you're new to programming, Hartl helps you quickly build technical sophistication as you gain a solid understanding of JavaScript for object-oriented and functional programming, including making JavaScript modules with test-driven development and Node.js. Focused exercises help you internalize what matters, without wasting time on details pros don't care about. Soon, it'll be like you were born knowing this stuff--and you'll be suddenly, seriously dangerous.

About the Instructor

Michael Hartl is the creator of the Ruby on Rails Tutorial, one of the leading introductions to web development, and is cofounder and principal author at Learn Enough. Previously, he was a physics instructor at the California Institute of Technology (Caltech), where he received a Lifetime Achievement Award for Excellence in Teaching. He is a graduate of Harvard College, has a PhD in physics from Caltech, and is an alumnus of the Y Combinator entrepreneur program.

Skill Level

  • Beginner to intermediate

Learn How To

  • Create a simple hello, world program using several different techniques
  • Deploy a simple dynamic JavaScript application to the web
  • Use strings, arrays, and other native objects
  • Define functions
  • Use JavaScript for functional programming
  • Utilize test-driven development and publish a Node module
  • Write shell scripts
  • Develop an interactive JavaScript image gallery application

Who Should Take This Course

  • New programmers and developers looking for a practical introduction to JavaScript

Course Requirements

  • The only prerequisites are a familiarity with basic developer tools (command line, text editor, and Git) plus beginning HTML and a little CSS
  • Some programming experience is useful but not required

Lesson Descriptions

Lesson 1: Hello World!
In Lesson 1, you begin your study of JavaScript with four variations on the time-honored theme of a "Hello, World!" program. The main purpose of "Hello, World!" is to confirm that your system is correctly configured to execute a simple program that prints the string "Hello, World!" or some close variant to the screen. By design, the program is simple, enabling you to focus on the challenge of getting the program to run in the first place. In order to give you the best broad-range introduction to programming with JavaScript, Learn Enough JavaScript to Be Dangerous uses four main methods: one, front-end JavaScript programs running in the user's browser; two, an interactive prompt with a Node.js read, evaluate, print, loop, also called a REPL; three, standalone JavaScript files, including the Node Package Manager; and four, shell scripts, introduced in Learn Enough Developer Tools to Be Dangerous. Since the original and still most common application of JavaScript is to write programs that execute on the web, we'll start by writing and deploying a program to display "Hello, World!" in a web browser. We'll then write a series of three programs using the JavaScript execution system, Node.js, first in the node REPL, then in a JavaScript library file called hello.js, and finally, in an executable shell script simply called hello.

Lesson 2: Strings
Lesson 2 covers strings, probably the most important data structure on the Web since web pages ultimately consist of strings and characters sent to and from the browser. Many other kinds of programs require string manipulation as well. Thus, strings are a great place to start your Ruby programming journey. The lesson starts with what strings are and how to create them, including both single- and double-quoted strings. You then learn how to join, or concatenate, one string to another. Next, you learn how to print to the screen from the terminal window. As part of this, you see your first examples of JavaScript boolean variables and control flow. Finally, you learn how to iterate over strings with for loops, enabling you to access strings one character at a time.

Lesson 3: Arrays
In Lesson 3, you learn about the array data type, which is the general JavaScript container for arbitrary elements in a particular order. You start by explicitly connecting strings and arrays via the string split method and then learn about various array methods throughout the rest of the lesson. After learning to split strings you see how to access elements in the resulting array. You discover that the same syntax works on strings, further deepening the connection between the two data types. Next, you learn a variety of additional array methods beginning with selecting both single elements and multiple elements at once using array slicing, including a clever technique using negative indices to select the last element in an array. Then you learn how to sort arrays, discovering en route that JavaScript's default sorting algorithm is less than useful for numerical arrays, an issue addressed in Lesson 5. You also learn how to reverse an array, an ability put to good use later in the tutorial when learning to detect palindromes. Next, you see how to add and remove array elements using push and pop and then learn how to undo a string split with an array join. Finally, you learn how to iterate through arrays using the same kind of for loop covered in Lesson 2, which is valuable preparation for the more advanced techniques covered in Lessons 5 and 6.

Lesson 4: Other Native Objects
In Lesson 4 you continue with the tour of some other important JavaScript objects, which gives you a chance to learn about math, dates, regular expressions, and generic objects. Like most programming languages, JavaScript supports a large number of mathematical operations right out of the box, such as addition, subtraction, multiplication, and division. It also includes a math library. It also supports more advanced operations like logarithms and trigonometric functions. You also learn how to deal with dates in JavaScript, such as getting the year, the day, or the exact time. This gives you your first chance to use the new function, a so-called constructor function. That is the standard JavaScript way to create a new object. This lesson includes an introduction to the powerful subject of regular expressions, which were discussed briefly in Learn Enough Developer Tools to Be Dangerous in the context of text editors and the grep command. Often called regexes, regular expressions are a powerful mini language for matching patterns in text. You'll learn how to use regexes to quickly search strings for things like five digits in a row, thereby matching standard United States ZIP codes. The lesson ends with an introduction to plain objects in JavaScript. We'll use such objects to create collections of keyvalue pairs, sometimes known as associative arrays, which are like regular arrays but with strings instead of integers as indices. You apply this important object type to write your first substantial JavaScript program, a shell script to count the unique words in a text.

Lesson 5: Functions
In Lesson 5, you learn how to define JavaScript functions, which enables powerful techniques like forEach, which is covered in this lesson, and functional programming, which is the subject of Lesson 6. You begin with a discussion of a couple of equivalent ways to define JavaScript functions, including the more recent fat arrow notation, which can look really confusing if you haven't seen it before. As part of this, you learn how to sort JavaScript arrays numerically, thereby fixing a blemish encountered in Lesson 3. You begin your study of functions in the read-eval-print loop, that is, the REPL. Then you learn how to put your function definitions in a file for later use. The lesson also covers how to use multiple functions in a row, a technique known as method chaining. You use method chaining to make a first definition of a palindrome function to see if a string is the same forward and backward. The lesson ends with the discussion of the forEach method for iterating through arrays, which often provides a more convenient way of processing array elements than the for loop introduced in Lesson 2.

Lesson 6: Functional Programming
Having learned how to define functions and apply them in a couple of different contexts, in Lesson 6 you take your programming to the next level by learning the basics of functional programming. This is a challenging lesson and you may have to watch it a couple of times to absorb everything, but the rewards are rich indeed. The lesson focuses on a triumvirate of functions commonly used in functional programming known as map, filter, and reduce. The first of the examples is the map function, which lets you map a function over an array of elements. It is often a powerful alternative to looping. So far, you have been using a style of coding known as imperative programming, but you see how to use map to take a five-line loop and condense it to a single line. This sort of compression is common in functional programming. The second function covered is filter, which enables you to filter your data based on some boolean criterion. This lets you run through an array and filter out anything that doesn't match your criterion. For example, you could take an array of integers and filter for only numbers evenly divisible by two, giving us a quick way to select only the even numbers in the array. Our third function is the mighty reduce, which is exactly the kind of powerful technique that can take lots of examples to really sink in but enables us to write remarkably clean and concise code. Because reduce, and indeed all functional techniques, can be challenging to understand even for experienced developers, it's especially powerful when combined with test-driven development, which is covered in Lesson 8, but first you need to learn how to define objects of your own.

Lesson 7: Objects and Prototypes
In Lesson 7 you learn how to make more general versions of JavaScript objects, ones that have both properties, which are data, and methods, which are functions, attached to them. There is a dizzying variety of ways to define objects in JavaScript, but this lesson focuses on one of the most classic ways, which is to use functions, which were first covered in Lesson 5. The result will be an object constructor function that can be used to create or instantiate a new object called an instance using the new method you saw in Lesson 4. This will give you the background needed to understand JavaScript's object system, which is based on template objects and a prototype chain. If that doesn't seem perfectly clear, don't worry, it's not. Nobody ever understood object systems by hearing definitions like that one. Instead, we look at a series of objects of increasing complexity, enabling you to understand the essence of JavaScript objects by generalizing from concrete examples. In particular, you create a Phrase object that knows whether or not the phrase is a palindrome. You then add a TranslatedPhrase object that overrides the main palindrome method and substitutes a translated phrase instead. Then you use the powerful, even dangerous, practice of modifying native JavaScript objects. This enables you to modify the string prototype itself, giving every string the ability to tell whether or not it is a palindrome.

Lesson 8: Testing and Test-Driven Development
Although rarely covered in introductory programming tutorials, automated testing is one of the most important subjects in modern software development. Accordingly, Lesson 8 gives you an introduction to testing in JavaScript, including a first look at test-driven development, or TDD. Test-driven development came up briefly in Lesson 6, which promised that you would use testing techniques to add an important capability to finding palindromes, namely, being able to detect complicated palindromes such as "A man, a plan, a canal--Panama!" or "Madam I'm Adam." This lesson fulfills that promise. You start by setting up your system for testing using the popular Mocha testing framework. The strategy for testing the current palindrome code and extending it to more complicated phrases is as follows: one, set up your system for automated testing; two, write automated tests for the existing palindrome functionality; three, write a failing test for the enhanced palindrome detector, also known as red (the first step in the TDD cycle known as red-green-refactor); four, write possibly ugly code to get the test passing, also known as green, which is the second step in the cycle; five, refactor the code, which involves changing its form without changing its function. The test suite should remain green even after refactoring, thereby completing the red-green-refactor cycle. As it turns out, learning how to write JavaScript tests will also give you a chance to learn how to create and publish self-contained software packages called NPM modules, another valuable skill for modern JavaScript programming.

Lesson 9: Events and DOM Manipulation
In Lesson 9, you return to JavaScript's native environment and put your newly created Node module to work in the browser, including our first example of manipulating the Document Object Model, or DOM. Specifically, you make a simple single-page JavaScript application that takes in a string from the user and indicates whether or not that string is a palindrome. The approach involves gradually increasing levels of sophistication, starting with a simple "hello world"style proof of concept. Then you add a prompt/alert design that will motivate the introduction of event listeners. This involves adding a piece of code that waits for a particular event to happen and then responds appropriately. In this case, the listener will wait for a button to be clicked and then prompt the user to enter a string, which will then test to see whether it's a palindrome. Next, you replace the alert with dynamic HTML inserted on the page itself. Finally, you add an HTML form, which is a more convenient method for entering data than a JavaScript prompt. As part of this, you update the event listener to respond by updating the page itself when the user submits the form, thereby creating a fully functional palindrome detector.

Lesson 10: Shell Scripts with Node.js
In Lesson 10, you return to the world of the command line and use Node.js to write three shell scripts of increasing sophistication. This use of JavaScript is currently less common than JavaScript in the browser, but it can be expected to grow as JavaScript, especially via Node and npm, continues to expand past its original web programming niche. These programs also serve as a useful foundation for similar programs written in languages more traditionally thought of as scripting languages, such as Perl, Python, and Ruby. Perhaps surprisingly, you will discover that the Document Object Model manipulation skills developed in Lesson 9 are still useful in shell scripts. Indeed, you extend your capability significantly in exactly the direction needed for the more advanced manipulations used in Lesson 11. The first program in this lesson shows how to use JavaScript to read and process the contents of a file from the file system. The next program then shows how to accomplish the similar feat of reading the contents of a URL. Finally, you write a real-life utility program.

Lesson 11: Full Sample App: Image Gallery
In Lesson 11, you apply the techniques from Lessons 9 and 10 to a real, industrial-grade website. In particular, this lesson extends the sample application from Learn Enough HTML, CSS and Layout to Be Dangerous to add a functional image gallery that dynamically changes images, CSS classes, and page text in response to user clicks. The result will be a professional-grade website deployed to the live Web.

About Pearson Video Training
Pearson publishes expert-led video tutorials covering a wide selection of technology topics designed to teach you the skills you need to succeed. These professional and personal technology videos feature world-leading author instructors published by your trusted technology brands: Addison-Wesley, Cisco Press, Pearson IT Certification, Sams, and Que. Topics include: IT Certification, Network Security, Cisco Technology, Programming, Web Development, Mobile Development, and more. Learn more about Pearson Video training at informit.com/video.

Video Lessons are available for download for offline viewing within the streaming format. Look for the green arrow in each lesson.

Sample Content

Table of Contents

Introduction

Lesson 1: Hello World!
Topics
1.1 Introduction to JavaScript
1.2 JS in a Web Browser
1.3 JS in REPL
1.4 JS in a File
1.5 JS in a Shell Script

Lesson 2: Strings
Topics
2.1 String Basics
2.2 Concatenation and Interpolation
2.3 Printing
2.4 Properties, Booleans and control flow
2.5 Methods
2.6 String Iteration

Lesson 3: Arrays
Topics
3.1 Splitting
3.2 Array Access
3.3 Array Slicing
3.4 More Array Methods
3.5 Array Iteration

Lesson 4: Other Native Objects
Topics
4.1 Math and Numbers
4.2 Dates
4.3 Regular Expressions
4.4 Plain Objects
4.5 Application: Unique Words

Lesson 5: Functions
Topics
5.1 Function Definitions
5.2 Functions in a File
5.3 Method Chaining
5.4 Iteration for Each

Lesson 6: Functional Programming
Topics
6.1 Map
6.2 Filter
6.3 Reduce

Lesson 7: Objects and Prototypes
Topics
7.1 Defining Objects
7.2 Prototypes
7.3 Modifying Native Objects

Lesson 8: Testing and Test-Driven Development
Topics
8.1 Testing Setup
8.2 Initial Test Coverage
8.3 Red
8.4 Green
8.5 Refactor

Lesson 9: Events and DOM Manipulation
Topics
9.1 A Working Palindrome Page
9.2 Event Listeners
9.3 Dynamic HTML
9.4 Form Handling

Lesson 10: Shell Scripts with Node.js
Topics
10.1 Reading from Files
10.2 Reading from URLs
10.3 DOM Manipulation at the Command Line

Lesson 11: Full Sample App: Image Gallery
Topics
11.1 Prepping the Gallery
11.2 Changing the Gallery Image
11.3 Setting an Image as Current
11.4 Changing the Image Info
11.5 Conclusion

Summary

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020