3 options
Mastering JavaScript functional programming : in-depth guide for writing robust and maintainable JavaScript codes in ES8 and beyond / Federico Kereki.
- Format:
- Book
- Author/Creator:
- Kereki, Federico, author.
- Language:
- English
- Subjects (All):
- JavaScript (Computer program language).
- Computer programming.
- Physical Description:
- 1 online resource (1 volume) : illustrations
- Edition:
- 1st edition
- Place of Publication:
- Birmingham, England ; Mumbai, [India] : Packt Publishing, 2017.
- System Details:
- text file
- Biography/History:
- Kereki Federico: Federico Kereki is a Uruguayan Systems Engineer, with a Master's degree in Education, and over 30 years of experience as a consultant, system developer, and writer. Currently a Subject Matter Expert at Globant, he has taught at Universidad de la Republica, Universidad ORT Uruguay, and Universidad de la Empresa. He has written articles and booklets on programming, web development, security, and open source topics for blogs, magazines, and websites. He has also written several books, including Modern JavaScript Web Development Cookbook and the upcoming Data Structures and Algorithms in JavaScript. He resides, works, and teaches in Uruguay, but he wrote the first edition of this book while working in India, and the second edition during a sojourn in Mexico.
- Summary:
- Master Functional Programming techniques with this comprehensive guide for writing cleaner, safer, high-performing JavaScript codes About This Book Become proficient and skilled with Functional Programming in JavaScript to solve real-world development problems Successfully apply Functional Programming concepts and techniques to everyday JavaScript programming Bring modularity, reusability, testability, and performance to your web apps Who This Book Is For If you are a JavaScript developer and want to apply functional programming techniques, then this book is for you. Only a basic knowledge of the concepts of functional programming is required for this book. What You Will Learn Create more reliable code with closures and immutable data Convert existing methods into pure functions, and loops into recursive methods Develop more powerful applications with currying and function composition Separate the logic of your system from implementation details Implement composition and chaining techniques to simplify coding Use functional programming techniques where it makes the most sense In Detail Functional programming is a programming paradigm for developing software using functions. Learning to use functional programming is a good way to write more concise code, with greater concurrency and performance. The JavaScript language is particularly suited to functional programming. This book provides comprehensive coverage of the major topics in functional programming with JavaScript to produce shorter, clearer, and testable programs. You’ll delve into functional programming; including writing and testing pure functions, reducing side-effects, and other features to make your applications functional in nature. Specifically, we’ll explore techniques to simplify coding, apply recursion for loopless coding, learn ways to achieve immutability, implement design patterns, and work with data types. By the end of this book, you’ll have developed the JavaScript skills you need to program functional applications with confidence. Style and approach This book takes an easy-to-follow, step-by-step tutorial approach. You will make the most of JavaScript programming with a focus on the progression of functional programming techniques, styles, and detailed information about JavaScript libraries. Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purcha...
- Contents:
- Cover
- Title Page
- Copyright
- Credits
- About the Author
- Dedication
- About the Reviewer
- www.PacktPub.com
- Customer Feedback
- Table of Contents
- Preface
- Chapter 1: Becoming Functional - Several Questions
- What is Functional Programming?
- Theory versus practice
- A different way of thinking
- What Functional Programming is not
- Why use Functional Programming?
- What we need
- What we get
- Not all is gold...
- Is JavaScript functional?
- JavaScript as a tool
- Going functional with JavaScript
- Key features of JavaScript
- Functions as First Class Objects
- Recursion
- Closures
- Arrow functions
- Spread
- How do we work with JavaScript?
- Using transpilers
- Working online
- Testing
- Questions
- Summary
- Chapter 2: Thinking Functionally - A First Example
- The problem - do something only once
- Some bad solutions
- Solution #1 - hope for the best!
- Solution #2 - use a global flag
- Solution #3 - remove the handler
- Solution #4 - change the handle
- Solution #5 - disable the button
- Solution #6 - redefine the handler
- Solution #7- use a local flag
- A functional solution
- A higher-order solution
- Testing the solution manually
- Testing the solution automatically
- An even better solution
- Chapter 3: Starting Out with Functions - A Core Concept
- All about functions
- Of lambdas and functions
- Arrow functions - the modern way
- Returning values
- Handling the this value
- Working with arguments
- One argument or many?
- Functions as objects
- A React+Redux reducer
- An unnecessary mistake
- Working with methods
- Using functions in FP ways
- Injection - sorting it out
- Callbacks, promises, and continuations
- Continuation Passing Style
- Polyfills
- Detecting Ajax
- Adding missing functions
- Stubbing
- Immediate invocation.
- Questions
- Chapter 4: Behaving Properly - Pure Functions
- Pure functions
- Referential Transparency
- Side effects
- Usual side effects
- Global state
- Inner state
- Argument mutation
- Troublesome functions
- Advantages of pure functions
- Order of execution
- Memoization
- Self-documentation
- Impure functions
- Avoiding impure functions
- Avoiding the usage of state
- Injecting impure functions
- Is your function pure?
- Testing - pure versus impure
- Testing pure functions
- Testing purified functions
- Testing impure functions
- Chapter 5: Programming Declaratively - A Better Style
- Transformations
- Reducing an array to a value
- Summing an array
- Calculating an average
- Calculating several values at once
- Folding left and right
- Applying an operation - map
- Extracting data from objects
- Parsing numbers tacitly
- Working with ranges
- Emulating map() with reduce()
- More general looping
- Logical higher-order functions
- Filtering an array
- A reduce() example
- Emulating filter() with reduce()
- Searching an array
- A special search case
- Emulating find() and findIndex() with reduce()
- Higher level predicates - some, every
- Checking negatives - none
- Chapter 6: Producing Functions - Higher-Order Functions
- Wrapping functions
- Logging
- Logging in a functional way
- Taking exceptions into account
- Working in a more pure way
- Timing
- Memoizing
- Simple memoization
- More complex memoization
- Memoization testing
- Altering functions
- Doing things once, revisited
- Logically negating a function
- Inverting results
- Arity changing
- Other higher-order functions
- Turning operations into functions
- Implementing operations
- A handier implementation
- Turning functions into promises.
- Getting a property from an object
- Demethodizing - turning methods into functions
- Finding the optimum
- Chapter 7: Transforming Functions - Currying and Partial Application
- A bit of theory
- Currying
- Dealing with many parameters
- Currying by hand
- Currying with bind()
- Currying with eval()
- Partial application
- Partial application with arrow functions
- Partial application with eval()
- Partial application with closures
- Partial currying
- Partial currying with bind()
- Partial currying with closures
- Final thoughts
- Parameter order
- Being functional
- Chapter 8: Connecting Functions - Pipelining and Composition
- Pipelining
- Piping in Unix/Linux
- Revisiting an example
- Creating pipelines
- Building pipelines by hand
- Using other constructs
- Debugging pipelines
- Using tee
- Tapping into a flow
- Using a logging wrapper
- Chaining and fluent interfaces
- Pointfree style
- Defining pointfree functions
- Converting to pointfree style
- Composing
- Some examples of composition
- Unary operators
- Counting files
- Finding unique words
- Composing with higher order functions
- Testing composed functions
- Chapter 9: Designing Functions - Recursion
- Using recursion
- Thinking recursively
- Decrease and Conquer: searching
- Decrease and Conquer: doing powers
- Divide and conquer: The Tower of Hanoi
- Divide and conquer: sorting
- Dynamic programming: making change
- Higher order functions revisited
- Mapping and filtering
- Searching and backtracking
- The Eight Queens puzzle
- Traversing a tree structure
- Recursion techniques
- Tail call optimization
- Continuation passing style
- Trampolines and thunks
- Recursion elimination
- Summary.
- Chapter 10: Ensuring Purity - Immutability
- The straightforward JS way
- Mutator functions
- Constants
- Freezing
- Cloning and mutating
- Getters and setters
- Getting a property
- Setting a property by path
- Persistent data structures
- Working with lists
- Updating objects
- A final caveat
- Chapter 11: Implementing Design Patterns - The Functional Way
- What are Design Patterns?
- Design pattern categories
- Do we need design patterns?
- Object-oriented design patterns
- Façade and Adapter
- Decorator or Wrapper
- Strategy, Template, and Command
- Other patterns
- Functional design patterns
- Chapter 12: Building Better Containers - Functional Data Types
- Data types
- Signatures for functions
- Other type options
- Containers
- Extending current data types
- Containers and functors
- Wrapping a value: a basic container
- Enhancing our container: functors
- Dealing with missing values with Maybe
- Monads
- Adding operations
- Handling alternatives - the Either monad
- Calling a function - the Try monad
- Unexpected Monads - Promises
- Functions as data structures
- Binary trees in Haskell
- Functions as binary trees
- Bibliography
- Appendix: Answers to Questions
- Index.
- Notes:
- Includes bibliographical references and index.
- Description based on online resource; title from PDF title page (EBC, viewed December 29, 2017).
- ISBN:
- 9781787289734
- 1787289737
- OCLC:
- 1018480586
The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.