JavaScript by Example

Book description

A project based guide to help you get started with web development by building real-world and modern web applications

About This Book

  • Learn JavaScript from scratch by building clones of popular web applications
  • Understand the core concepts and techniques surrounding JavaScript with this power-packed hands-on guide
  • Explore modern JavaScript frameworks and libraries such as Node, React and Webpack

Who This Book Is For

The target audience for this book is developers with little or basic knowledge of working with JavaScript. If you are an emerging web developer with experience in building static web pages using HTML and CSS, this book will teach you to add JavaScript elements to make your website interactive and dynamic.

What You Will Learn

  • A strong understanding of web application development with JavaScript and ES6.
  • A firm foundation on which to master other JavaScript frameworks and libraries.
  • Write maintainable and scalable code by organizing functions into modules.
  • Importance of tools such as Node, NPM, Babel, and Webpack in Front-end development.
  • Work with real-time data such as incoming video streams, texts, and so on
  • Integrate React with JavaScript to build large-scale applications.
  • Utilize Redux to manage data across React components and greatly speed up the development process

In Detail

JavaScript is the programming language that all web developers need to learn. The first item on our JavaScript to-do list is building g a To-do list app, which you'll have done by the end of the first chapter. You'll explore DOM manipulation with JavaScript and work with event listeners. You'll work with images and text to build a Meme creator. You will also learn about ES (ECMAScript) classes, and will be introduced to layouts using the CSS3 Flexbox.

You'll also develop a responsive Event Registration form that allows users to register for your upcoming event and use charts and graphics to display registration data. You will then build a weather application, which will show you different ways perform AJAX requests and work with dynamic, external data. WebRTC enables real-time communication in a web browser; you'll learn how to use it when you build a real-time video-call and chat application later in the book.

Towards the end of the book, you will meet React, Facebook's JavaScript library for building user interfaces. You'll throw together a blog with React, and get a feel for why this kind of JavaScript framework is used to build large-scale applications. To make your blog more maintainable and scalable, you'll use Redux to manage data across React components.

Style and approach

This project-based guide will teach you all the facets of JavaScript through real-world app examples.

Publisher resources

Download Example Code

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Errata
      3. Piracy
      4. Questions
  2. Building a ToDo List
    1. System requirements
      1. Text editor
      2. Node.js
        1. For Windows users
        2. For Linux users
        3. For Mac users
      3. Google Chrome
    2. ToDo List app
      1. Chrome DevTools
      2. Getting started with ES6
        1. Arrow functions
        2. let, var, and const
        3. Loading the tasks from data
        4. Template literals
        5. Managing task status
        6. Adding new tasks to the list
        7. Adding tasks by hitting Enter button
        8. Persisting data in the browser
        9. Compatibility with older browsers
        10. Node.js and npm
    3. Setting up our development environment with Node and Babel
      1. Shipping the code
    4. Summary
  3. Building a Meme Creator
    1. Initial project setup
      1. Responsive designing with flexbox
        1. Flexbox - a quick introduction
        2. Designing the Meme Creator
          1. Navigation bar
          2. Content area
    2. Webpack module bundler
      1. Modules in JavaScript
      2. Bundling modules in Webpack
      3. Loaders in Webpack
        1. Bundling Bootstrap in Webpack
          1. Plugins in Webpack
      4. Webpack dev server
      5. Optimizing Webpack builds for different environments
        1. Creating .env file in Windows
        2. UglifyJsPlugin
        3. PurifyCSSPlugin
        4. ExtractTextPlugin
        5. Cache busting
        6. Clean dist folder before generating a new build
        7. Source maps in production
    3. Building the Meme Creator
      1. Event handling
      2. Rendering an image in the canvas
        1. Reading a file using JavaScript
      3. Rendering text on the canvas
        1. Making a canvas responsive to show large images
    4. Summary
  4. Event Registration App
    1. Event - JS meetup
    2. Initial project setup
      1. Adding styles to the page
    3. Validating and submitting the form using JavaScript
      1. HTML forms
      2. Reading form data in JavaScript
      3. Form validation module
        1. Working with regular expressions in JavaScript
      4. Submitting the form using AJAX
        1. Making network requests in JavaScript
        2. What is a Promise?
        3. Creating the API call module
          1. Constructing the request details
          2. Other network request methods
        4. Back to the form
    4. Adding charts to the website using Chart.js
      1. Adding charts to the canvas elements
      2. Setting up tab sections
    5. Adding Google Maps to the web page
      1. Adding Google Maps with a marker
    6. Generating a production build
      1. Shipping the code
    7. Summary
  5. Real-Time Video Call App with WebRTC
    1. Introduction to WebRTC
      1. History of WebRTC
      2. JavaScript WebAPIs
      3. JavaScript WebRTC API
        1. MediaStream
          1. Using Adapter.js library
        2. RTCPeerConnection and RTCDataChannel
    2. Building the Video Call application
    3. Initial project setup
    4. Adding styles to the page
    5. Building the Video Call app
      1. Creating a room
      2. Adding participants to your room
        1. Click to copy text
        2. Joining a room
          1. Setters and getters
      3. Adding and removing videos
        1. Selecting a video
      4. Video Call in action
    6. Summary
  6. Developing a Weather Widget
    1. Can you build a Weather Widget?
    2. Introduction to web components
      1. HTML templates
      2. HTML imports
    3. Building the Weather Widget
      1. Working of the Weather Widget
      2. Retrieving the geolocation
      3. Creating the weather custom element
        1. Testing the custom element
      4. Attaching a shadow DOM
      5. Working with the custom element
        1. Adding dependency modules
        2. Retrieving and displaying weather information
        3. Adding the current time to the widget
        4. Responding to changes in element attributes
        5. Using setters and getters
      6. Fixing browser compatibility
      7. Essential things to know
    4. Summary
  7. Building a Blog with React
    1. Why use a framework?
      1. Selecting a framework
    2. React
      1. Immutable state
      2. Props
      3. Building the Counter
    3. The React crash course
      1. Adding and managing states
        1. Managing the state for the input field
        2. Managing the state for the tasks
        3. Adding new tasks
          1. Preventing mutations using the spread syntax
      2. Advantages of using React
        1. Performance
        2. Maintainability
        3. Size
    4. Building a blog with React
      1. Creating the navigation bar
      2. Implementing routing and navigation using React Router
        1. The routes file
        2. Adding routes in the app component
        3. Managing history using withRouter
        4. Proptype validation
        5. Seamless navigation with NavLink
      3. Blog home page
        1. Using child components
        2. Displaying post details
      4. Adding a new blog post
        1. Submitting the post
      5. Generating production builds
    5. Summary
  8. Redux
    1. What is Redux?
      1. Flux
      2. Introduction to Redux
        1. Store
        2. Actions
        3. Reducers
    2. Implementing Redux in the blog
      1. The folder structure
      2. Initial state
      3. Action types
      4. Actions
        1. Get all posts
        2. Adding a new post
      5. Reducers
        1. The Root Reducer
      6. Store
      7. Connecting Redux with React components
        1. The App component
        2. Home component
        3. Post component
        4. The NewPost component
      8. The Redux data flow
      9. Persisting Redux store
    3. Summary

Product information

  • Title: JavaScript by Example
  • Author(s): Dani Akash S
  • Release date: August 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781788293969