Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
JavaScript: Moving to ES2015
JavaScript: Moving to ES2015
Credits
Preface
What this learning path covers
What you need for this learning path
Who this learning path is for
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Module 1
1. JavaScript Primer
A little bit of history
How to use this module
Hello World
An overview of JavaScript
Comments
Variables
Constants
Number
String
Undefined values
Booleans
The instanceof operator
Date objects
The + operator
The ++ and -- operators
Boolean operators
Equality
Strict equality using ===
Weak equality using ==
JavaScript types
Automatic semicolon insertion
JavaScript style guide
Whitespaces
Parentheses, line breaks, and braces
Quotes
End of lines and empty lines
Type checking
Type casting
Conditional evaluation
Naming
The eval() method is evil
The strict mode
Enabling the strict mode for an existing code can break it
Package with care
Variables must be declared in strict mode
The eval() function is cleaner in strict mode
Features that are blocked in strict mode
Running JSHint
Summary
2. Functions, Closures, and Modules
A function literal
A function declaration
Functions as data
Scoping
Global scope
Local scope
Function-level scope versus block-level scope
Inline function expressions
Block scopes
Function declarations versus function expressions
The arguments parameter
The this parameter
Invocation as a function
Invocation as a method
Invocation as a constructor
Invocation using apply() and call() methods
Anonymous functions
Anonymous functions while creating an object
Anonymous functions while creating a list
Anonymous functions as a parameter to another function
Anonymous functions in conditional logic
Closures
Timers and callbacks
Private variables
Loops and closures
Modules
Stylistic considerations
Summary
3. Data Structures and Manipulation
Regular expressions
Exact match
Match from a class of characters
Repeated occurrences
Alternatives – OR
Beginning and end
Backreferences
Greedy and lazy quantifiers
Arrays
Maps
Sets
A matter of style
Summary
4. Object-Oriented JavaScript
Understanding objects
Behavior of JavaScript objects
Prototypes
Instance properties versus prototype properties
Inheritance
Getters and setters
Summary
5. JavaScript Patterns
Design patterns
The namespace pattern
The module pattern
ES6 modules
The factory pattern
The mixin pattern
The decorator pattern
The observer pattern
JavaScript Model-View-* patterns
Model-View-Controller
Models
Views
Controllers
The Model-View-Presenter pattern
Model-View-ViewModel
Summary
6. Testing and Debugging
Unit testing
Test-driven development
Behavior-driven development
JavaScript debugging
Syntax errors
Using strict
Runtime exceptions
Console.log and asserts
Chrome DevTools
Summary
7. ECMAScript 6
Shims or polyfills
Transpilers
ES6 syntax changes
Block scoping
Default parameters
Spread and rest
Destructuring
Object literals
Template literals
Maps and Sets
Symbols
Iterators
For..of loops
Arrow functions
Summary
8. DOM Manipulation and Events
DOM
Accessing DOM elements
Accessing specific nodes
Chaining
Traversal and manipulation
Working with browser events
Propagation
jQuery event handling and propagation
Event delegation
The event object
Summary
9. Server-Side JavaScript
An asynchronous evented-model in a browser
Callbacks
Timers
EventEmitters
Modules
Creating modules
npm
Installing packages
JavaScript performance
JavaScript profiling
The CPU profile
The Timeline view
Summary
2. Module 2
1. Designing for Fun and Profit
The road to JavaScript
The early days
A pause
The way of GMail
JavaScript everywhere
What is a design pattern?
Anti-patterns
Summary
1. Classical Design Patterns
2. Organizing Code
Chunks of code
What's the matter with global scope anyway?
Objects in JavaScript
Build me a prototype
Inheritance
Modules
ECMAScript 2015 classes and modules
Best practices and troubleshooting
Summary
3. Creational Patterns
Abstract factory
Implementation
Builder
Implementation
Factory method
Implementation
Singleton
Implementation
Disadvantages
Prototype
Implementation
Tips and tricks
Summary
4. Structural Patterns
Adapter
Implementation
Bridge
Implementation
Composite
Example
Implementation
Decorator
Implementation
Façade
Implementation
Flyweight
Implementation
Proxy
Implementation
Hints and tips
Summary
5. Behavioral Patterns
Chain of responsibility
Implementation
Command
Command message
Invoker
Receiver
Interpreter
Example
Implementation
Iterator
Implementation
ECMAScript 2015 iterators
Mediator
Implementation
Memento
Implementation
Observer
Implementation
State
Implementation
Strategy
Implementation
Template method
Implementation
Visitor
Hints and tips
Summary
2. Other Patterns
6. Functional Programming
Functional functions are side-effect-free
Function passing
Implementation
Filters and pipes
Implementation
Accumulators
Implementation
Memoization
Implementation
Immutability
Lazy instantiation
Implementation
Hints and tips
Summary
7. Reactive Programming
Application state changes
Streams
Filtering streams
Merging streams
Streams for multiplexing
Hints and tips
Summary
8. Application Patterns
First, some history
Model View Controller
MVC code
Model View Presenter
MVP code
Model View ViewModel
MVVM code
A better way to transfer changes between the model and the view
Observing view changes
Tips and tricks
Summary
9. Web Patterns
Sending JavaScript
Combining files
Minification
Content Delivery Networks
Plugins
jQuery
d3
Doing two things at once – multithreading
Circuit breaker pattern
Back-off
Degraded application behavior
Promise pattern
Hints and tips
Summary
10. Messaging Patterns
What's a message anyway?
Commands
Events
Request-reply
Publish-subscribe
Fan out and in
Dead letter queues
Message replay
Pipes and filters
Versioning messages
Hints and tips
Summary
11. Microservices
Façade
Service selector
Aggregate services
Pipeline
Message upgrader
Failure patterns
Service degradation
Message storage
Message replay
Indempotence of message handling
Hints and tips
Summary
12. Patterns for Testing
The testing pyramid
Testing in the small with unit tests
Arrange-Act-Assert
Assert
Fake objects
Test spies
Stubs
Mock
Monkey patching
Interacting with the user interface
Browser testing
Faking the DOM
Wrapping the manipulation
Tips and tricks
Summary
13. Advanced Patterns
Dependency injection
Live post processing
Aspect oriented programming
Mixins
Macros
Tips and tricks
Summary
14. ECMAScript-2015/2016 Solutions Today
TypeScript
Decorators
Async/Await
Typing
BabelJS
Classes
Default parameters
Template literals
Block bindings with let
In production
Tips and tricks
Summary
3. Module 3
1. Breaking into Microservices Architecture
What is monolithic architecture?
Demerits of monolithic architecture
Scaling monolithic architecture
Writing monolithic server-side applications
Other issues of monolithic architecture
Microservices architecture to the rescue
Merits of microservices architecture
Scaling services
Demerits of microservices architecture
When to use microservices architecture
Data management
Implementing microservices using Seneca
Creating your first Seneca application
Creating actions
Creating plugins
Creating services
Storing data
Integrating Express and Seneca
Summary
2. Building a Coupon Site
Getting started
Architecture of our site
Creating the services
Database service
URL config service
Upload service
Creating the image upload server
Creating the monolithic core
Website walkthrough
Further improvements to the site
Summary
3. Communication between Browsers in Real Time
Terminologies
Stream
Peer-to-peer network model
Real-time data
Introduction to WebRTC
MediaStream API
navigator.getUserMedia
RTCPeerConnection API
Establishing peer-to-peer connection
Transferring MediaStream
RTCDataChannel API
WebRTC applications using PeerJS
PeerServer
PeerJS API
Miscellaneous
Summary
4. Building a Chatroulette
Creating your own PeerServer
Run PeerServer from shell
Using PeerServer library
Creating custom PeerServer
Integrating PeerServer with the Express server
Creating a chatroulette
Building the backend
Building the frontend
Testing the website
Summary
5. Bidirectional Communication in Real Time
Introducing WebSocket
The relationship between WebSocket and HTTP
Sending and receiving data on a WebSocket connection
WebSocket schemes
The interaction of WebSocket with proxy servers, load balancers, and firewalls
The same-origin policy for WebSocket
Introduction to Socket.IO
Setting up your project
Diving into the Socket.IO API
Restricting connections based on origin
Namespaces in Socket.IO
Referring to all connected Socket.IO clients
Rooms in Socket.IO
Joining and leaving a room
Referring to all connected Socket.IO clients in a room
Broadcasting messages and custom events to namespaces and rooms
Broadcasting to a namespace
Broadcasting to a room
Middleware in Socket.IO
Disconnecting manually
Summary
6. Building a Live Score Site
Building the backend
Integrating socket.io server with the Express server
Serving static files and HTML to the users
Serving HTML to the administrator and protecting the admin panel
Socket.IO cookie authentication and broadcasting messages to a namespace
Building the frontend
Testing the website
Summary
7. Functional Reactive Programming
Introduction to reactive programming
Problems with writing reactive code
Functional programming in a nutshell
The advantages of immutable data
Functional data structures
The advantages of pure functions
Functional programming with JavaScript
Functional programming helper functions
Getting started with FRP
EventStreams
Properties
FRP using Bacon.js
Setting up the project
Bacon.js APIs
Creating EventStreams
Creating properties
Merging, filtering, and transforming EventStreams and properties
Merging
Filtering
Transforming
Summary
8. Building an Advanced Profile Search Widget
Errors in Bacon.js
Subscribing to errors
Mapping errors
Retrying a function call
Ending an EventStream or property on error
Handling exceptions
Constant properties
An overview of buses
Subscribing to the end of EventStreams and properties
Unplugging subscribers
Combining and zipping
Lazy evaluation
Type 1
Type 2
Building the profile search widget
Understanding project directories and files
Converting Express.js routes to a functional reactive pattern
Making the user experience better
The company suggestions route
The search result route
Building the frontend
Testing the widget
Summary
9. New Features of Bootstrap 4
Downloading Bootstrap 4
Browser and device support
Understanding the rem and em CSS units
The grid system
Global margin reset
Spacing utility classes
Display headings
Inverse tables
The card component
Card groups, decks, and columns
Outline buttons
Moving from Less to Sass
Text alignment and float utility classes
Reboot
Flexbox support
JavaScript improvements
Adding Tether
The 21:9 aspect ratio class
Customizing Bootstrap 4
Glyphicons dropped
Summary
10. Building User Interfaces Using React
Introducing React
Setting up a basic React project
Virtual DOM
Components
One-way data binding
Isomorphic UI development
Getting started with JSX
Compiling JSX
JSX syntax
Digging into components
Component composition
Component ownership
Reconciliation
Default component property values
Component life cycle methods
componentWillMount()
componentDidMount()
componentWillReceiveProps(nextProps)
shouldComponentUpdate(nextProps, nextState)
componentWillUpdate(nextProps, nextState)
componentDidUpdate(prevProps, prevState)
componentWillUnmount()
Mixins
Using Refs
ReactDOMServer.renderToStaticMarkup
Summary
11. Building an RSS Reader Using React and Flux
Understanding Flux
Using Flux.js
Using MicroEvent.js
Introduction to React Router
Creating the RSS feed reader
Setting up the project directories and files
Building the backend
Building the frontend
Defining routes
Creating dispatcher, actions, and stores
Testing the application
Summary
12. New Features of Angular 2
The Angular 2 architecture
Introducing web components
Templates
Custom elements
Shadow DOM
Setting up an Angular 2 project
Angular 2 fundamentals
Styling components and shadow DOM
Angular 2 change detection
Understanding view children and content children
Getting the reference of components of content children and view children
Local template variables
Component lifecycle methods
Writing templates
Rendering a value
Pipes
Handling events
Binding state to element attributes
Two-way data binding
Directives
Attribute directives
Structural directives
Outputs
Two-way data binding with inputs and outputs
Understanding providers
The difference between providers and the viewProviders property
Summary
13. Building a Search Engine Template Using AngularJS 2
Setting up the project
Configuring routes and bootstrapping the app
Generating random search results
Creating route components
Testing the template
Routing life cycle methods
Production mode versus development mode
Summary
14. Securing and Scaling Node.js Applications
Common vulnerabilities in applications
Helmet
Cross-site request forgery
Cross-site scripting
Session fixation
Non-vulnerability based attacks
Denial-of-service attacks
Brute force attacks
Using secure packages
Scaling Node.js servers
Summary
Bibliography
Index
← Prev
Back
Next →
← Prev
Back
Next →