JavaScript: Functional Programming for JavaScript Developers
eBook - ePub

JavaScript: Functional Programming for JavaScript Developers

Ved Antani, Simon Timms, Dan Mantyla

Share book
  1. 635 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

JavaScript: Functional Programming for JavaScript Developers

Ved Antani, Simon Timms, Dan Mantyla

Book details
Book preview
Table of contents
Citations

About This Book

Unlock the powers of functional programming hidden within JavaScript to build smarter, cleaner, and more reliable web apps

About This Book

  • Write powerful code with the high-level functions that JavaScript offers
  • Discover what functional programming is, why it's effective, and how it's used in JavaScript
  • Understand and optimize JavaScript's hidden potential as a true functional language

Who This Book Is For

If you are a JavaScript developer interested in learning functional programming, looking for the quantum leap toward mastering the JavaScript language, or just want to become a better programmer in general, then this book is ideal for you. This guide is aimed at programmers, involved in developing reactive frontend apps, server-side apps that wrangle with reliability and concurrency, and everything in between.

What You Will Learn

  • Get a run through of the basic JavaScript language constructs
  • Code using the powerful object-oriented feature in JavaScript
  • Master DOM manipulation, cross-browser strategies, and ES6
  • Understand the basic concurrency constructs in Javascript and best performance strategies
  • Harness the power of patterns for tasks ranging from application building to code testing
  • Build large-scale apps seamlessly with the help of reactive patterns
  • Explore advanced design patterns, including dependency injection
  • Develop more powerful applications with currying and function composition
  • Create more reliable code with closures and immutable data

In Detail

JavaScript is a high-level, dynamic, untyped, lightweight, and interpreted programming language and functional programming is a style that emphasizes and enables smarter code that minimizes complexity and increases modularity. It's a way of writing cleaner code through clever ways of mutating, combining, and using functions. And JavaScript provides an excellent medium for this approach. By learning how to expose JavaScript's true identity as a functional language, we can implement web apps that are more powerful, easier to maintain and more reliable.

The java script: Functional Programming for JavaScript Developers course will take you on a journey to show how functional programming when combined with other techniques makes JavaScript programming more efficient.

The first module Mastering JavaScript, stress on practical aspects of Javascript development like—Functions and Closures, Runtime debugging techniques, project layout, events and DOM processing, build tools, Object-oriented patterns, isomorphism—everything that a modern Javascript project would need.

The second module, Mastering JavaScript Design Patterns - Second Edition, will explore how design patterns can help you improve and organize your JavaScript code. You'll get to grips with creational, structural, and behavioral patterns as you discover how to put them to work in different scenarios. This updated edition will also delve into reactive design patterns and microservices as they are a growing phenomenon in the world of web development. It will also show you some advanced patterns, including dependency injection and live post processing.

The third module, Functional Programming in JavaScript, will help you to write real-world applications by utilizing a wide range of functional techniques and styles. It explores the core concepts of functional programming common to all functional languages, with examples of their use in JavaScript.

Style and approach

This course will begin with providing insights and practical tips on advanced JavaScript features to build highly scalable web and mobile system and move on to some design patterns with JavaScript. Finally, the course ends with presenting the functional programming techniques and styles in JavaScript.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is JavaScript: Functional Programming for JavaScript Developers an online PDF/ePUB?
Yes, you can access JavaScript: Functional Programming for JavaScript Developers by Ved Antani, Simon Timms, Dan Mantyla in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation Web. We have over one million books available in our catalogue for you to explore.

Information

Year
2016
ISBN
9781787125575
Edition
1

JavaScript: Functional Programming for JavaScript Developers


Table of Contents

JavaScript: Functional Programming for JavaScript Developers
JavaScript: Functional Programming for JavaScript Developers
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 theexample code
Errata
Piracy
Questions
1. Module 1
1. JavaScript Primer
A little bit of history
How to use this book
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. 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
6. 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
7. 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
8. 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
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
Part 2
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. The Powers of JavaScript's Functional Side – a Demonstration
Introduction
The demonstration
The application – an e-commerce website
Imperative methods
Functional programming
Summary
2. Fundamentals of Functional Programming
Functional programming languages
What makes a language functional?
Advantages
Cleaner code
Modularity
Reusability
Reduced coupling
Mathematically correct
Functional programming in a nonfunctional world
Is JavaScript a functional programming language?
Working with functions
Self-invoking functions and closures
Higher-order functions
Pure functions
Anonymous functions
Method chains
Recursion
Divide and conquer
Lazy evaluation
The functional programmer's toolkit
Callbacks
Array.prototype.map()
Array.prototype.filter()
Array.prototy...

Table of contents