Mastering JavaScript

Book description

Explore and master modern JavaScript techniques in order to build large-scale web applications

About This Book

  • Write powerful code with the high-level functions that JavaScript offers
  • Test and debug issues with JavaScript code using various modern mechanisms
  • Offers an expert's eye on the latest ES6 features and how these advanced tasks fit together in JavaScript as a whole

Who This Book Is For

This book is ideal for web developers who are looking to master modern JavaScript concepts and design principles. You should already have an intermediate level of JavaScript knowledge before starting this book.

What You Will Learn

  • Get a run through of the basic JavaScript language constructs
  • Get familiar with the Functions and Closures of JavaScript
  • Explore Regular Expressions in JavaScript
  • Code using the powerful object-oriented feature in JavaScript
  • Test and debug your code using JavaScript strategies
  • Master DOM manipulation, cross-browser strategies, and ES6
  • Understand the basic concurrency constructs in Javascript and best performance strategies
  • Learn to build scalable server application in JavaScript using Node.js

In Detail

JavaScript is a high-level, dynamic, untyped, lightweight, and interpreted programming language. Along with HTML and CSS, it is one of the three essential technologies of World Wide Web content production, and is an open source and cross-platform technology. The majority of websites employ JavaScript, and it is well supported by all modern web browsers without plugins. However, the JavaScript landscape has changed dramatically in recent years, and you need to adapt to the new world of JavaScript that people now expect. Mastering modern JavaScript techniques and the toolchain are essential to develop web-scale applications.

Mastering JavaScript will be your companion as you master JavaScript and build innovative web applications. To begin with, you will get familiarized with the language constructs and how to make code easy to organize. You will gain a concrete understanding of variable scoping, loops, and best practices on using types and data structures, as well as the coding style and recommended code organization patterns in JavaScript. The book will also teach you how to use arrays and objects as data structures. You will graduate from intermediate-level skills to advanced techniques as you come to understand crucial language concepts and design principles. You will learn about modern libraries and tools so you can write better code.

By the end of the book, you will understand how reactive JavaScript is going to be the new paradigm.

Style and approach

This is a comprehensive guide with a clear focus on practical use cases and patterns. Each chapter consists of best practices, useful advice, and a bunch of easy-to-follow examples that will build up your skills as you advance through the book.

Table of contents

  1. Mastering JavaScript
    1. Table of Contents
    2. Mastering JavaScript
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. 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. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. JavaScript Primer
      1. A little bit of history
      2. How to use this book
      3. Hello World
        1. An overview of JavaScript
          1. Comments
          2. Variables
          3. Constants
          4. Number
          5. String
          6. Undefined values
          7. Booleans
          8. The instanceof operator
          9. Date objects
          10. The + operator
          11. The ++ and -- operators
          12. Boolean operators
          13. Equality
            1. Strict equality using ===
            2. Weak equality using ==
        2. JavaScript types
        3. Automatic semicolon insertion
        4. JavaScript style guide
          1. Whitespaces
          2. Parentheses, line breaks, and braces
          3. Quotes
          4. End of lines and empty lines
          5. Type checking
          6. Type casting
          7. Conditional evaluation
          8. Naming
          9. The eval() method is evil
          10. The strict mode
            1. Enabling the strict mode for an existing code can break it
            2. Package with care
            3. Variables must be declared in strict mode
              1. The eval() function is cleaner in strict mode
            4. Features that are blocked in strict mode
          11. Running JSHint
      4. Summary
    9. 2. Functions, Closures, and Modules
      1. A function literal
        1. A function declaration
      2. Functions as data
      3. Scoping
        1. Global scope
        2. Local scope
        3. Function-level scope versus block-level scope
        4. Inline function expressions
        5. Block scopes
      4. Function declarations versus function expressions
      5. The arguments parameter
        1. The this parameter
          1. Invocation as a function
          2. Invocation as a method
          3. Invocation as a constructor
          4. Invocation using apply() and call() methods
      6. Anonymous functions
        1. Anonymous functions while creating an object
        2. Anonymous functions while creating a list
        3. Anonymous functions as a parameter to another function
        4. Anonymous functions in conditional logic
      7. Closures
      8. Timers and callbacks
      9. Private variables
      10. Loops and closures
      11. Modules
        1. Stylistic considerations
      12. Summary
    10. 3. Data Structures and Manipulation
      1. Regular expressions
      2. Exact match
      3. Match from a class of characters
      4. Repeated occurrences
        1. Alternatives – OR
      5. Beginning and end
      6. Backreferences
      7. Greedy and lazy quantifiers
      8. Arrays
      9. Maps
      10. Sets
      11. A matter of style
      12. Summary
    11. 4. Object-Oriented JavaScript
      1. Understanding objects
        1. Behavior of JavaScript objects
        2. Prototypes
      2. Instance properties versus prototype properties
      3. Inheritance
      4. Getters and setters
      5. Summary
    12. 5. JavaScript Patterns
      1. Design patterns
      2. The namespace pattern
      3. The module pattern
        1. ES6 modules
      4. The factory pattern
      5. The mixin pattern
      6. The decorator pattern
      7. The observer pattern
      8. JavaScript Model-View-* patterns
        1. Model-View-Controller
        2. Models
        3. Views
        4. Controllers
      9. The Model-View-Presenter pattern
      10. Model-View-ViewModel
      11. Summary
    13. 6. Testing and Debugging
      1. Unit testing
        1. Test-driven development
        2. Behavior-driven development
      2. JavaScript debugging
        1. Syntax errors
        2. Using strict
        3. Runtime exceptions
          1. Console.log and asserts
          2. Chrome DevTools
      3. Summary
    14. 7. ECMAScript 6
      1. Shims or polyfills
      2. Transpilers
      3. ES6 syntax changes
        1. Block scoping
        2. Default parameters
        3. Spread and rest
        4. Destructuring
        5. Object literals
        6. Template literals
        7. Maps and Sets
        8. Symbols
        9. Iterators
        10. For..of loops
        11. Arrow functions
      4. Summary
    15. 8. DOM Manipulation and Events
      1. DOM
        1. Accessing DOM elements
        2. Accessing specific nodes
      2. Chaining
      3. Traversal and manipulation
      4. Working with browser events
      5. Propagation
      6. jQuery event handling and propagation
      7. Event delegation
      8. The event object
      9. Summary
    16. 9. Server-Side JavaScript
      1. An asynchronous evented-model in a browser
      2. Callbacks
      3. Timers
      4. EventEmitters
      5. Modules
        1. Creating modules
      6. npm
        1. Installing packages
      7. JavaScript performance
        1. JavaScript profiling
          1. The CPU profile
          2. The Timeline view
      8. Summary
    17. Index

Product information

  • Title: Mastering JavaScript
  • Author(s): Ved Antani
  • Release date: January 2016
  • Publisher(s): Packt Publishing
  • ISBN: 9781785281341