Simpson Kyle - Functional-Light JavaScript. Balanced, Pragmatic FP In JavaScript.pdf

(3075 KB) Pobierz
Functional-Light JavaScript
Balanced, Pragmatic FP in JavaScript
Kyle Simpson
This version was published on 2018-02-09
ISBN
9781617296512
Published by GetiPub (http://getipub.com), a division of Getify Solutions, Inc.
While the publisher and the author have used good faith efforts to ensure that the
information and instructions contained in this work are accurate, the publisher and
the author disclaim all responsibility for errors or omissions, including without
limitation responsibility for damages resulting from the use of or reliance on this
work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is
subject to open source licenses or the intellectual property rights of others, it is your
responsibility to ensure that your use thereof complies with such licenses and/or
rights.
DISTRIBUTED BY MANNING
This book was created solely by its Author and is being distributed by Manning
Publications “as is,” with no guarantee of completeness, accuracy, timeliness, or
other fitness for use. Neither Manning nor the Author make any warranty
regarding the results obtained from the use of the contents herein and accept no
liability for any decision or action taken in reliance on the information in this book
nor for any damages resulting from this work or its application.
© 2016 - 2018 Getify Solutions, Inc.
Tweet This Book!
Please help Kyle Simpson by spreading the word about this book on
Twitter!
The suggested tweet for this book is:
#FP #JS #FLJSBook Monads, and monoids, and functors, oh my!! I just discovered
”Functional-Light JavaScript”, a pragmatic take on FP in JS without all the crazy
terminology and math.
The suggested hashtag for this book is
#FLJSBook.
Find out what other people are saying about the book by clicking on this link to
search for this hashtag on Twitter:
#FLJSBook
I owe gratitude to dozens of folks in the JS and FP communities whose work has helped
me on my multiple-year journey to try to learn what FP is all about. I’m also grateful
to all 738 backers of my crowd-funding campaign (listed at the very end of the book),
who helped make this happen.
But I especially want to give a deep and profound thank you to Brian Lonsdorf for
allowing me to pester him endlessly with FP questions, and for being so patient and
attentive in his assistance. He even tech-edited this book, and wrote the Foreword.
You’re my FP hero, man!
Published by GetiPub (http://getipub.com), a division of Getify Solutions, Inc.
Editors: Brian MacDonald and Brian Lonsdorf
Copyeditor: Jasmine Kwityn
November 2017: First Edition
Revision History for the First Edition
2017-11-27: First Release
2017-12-05, 2017-12-14, 2018-01-29: Reformat For Print, Errata Updates
CONTENTS
Contents
Foreword
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Mission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Chapter 1: Why Functional Programming?
At a Glance . . . . . . . . . . . . . . . .
Confidence . . . . . . . . . . . . . . . .
Communication . . . . . . . . . . . . .
Readability . . . . . . . . . . . . . . . .
Perspective . . . . . . . . . . . . . . . .
How to Find Balance . . . . . . . . . . .
Resources . . . . . . . . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . .
Chapter 2: The Nature Of Functions
.
What Is a Function? . . . . . . . .
Function Input . . . . . . . . . . .
Named Arguments . . . . . . . . .
Function Output . . . . . . . . . .
Functions of Functions . . . . . . .
Syntax . . . . . . . . . . . . . . .
What’s This? . . . . . . . . . . . .
Summary . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
i
iii
iv
1
2
4
5
7
9
10
11
13
14
14
16
25
27
33
39
47
50
52
52
Chapter 3: Managing Function Inputs
. . . . . . . . . . . . . . . . . . . . .
All for One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Functional-Light JavaScript
Zgłoś jeśli naruszono regulamin