没有合适的资源?快使用搜索试试~ 我知道了~
首页Beginning Functional JavaScript, 2nd Edition (True PDF)
Beginning Functional JavaScript, 2nd Edition (True PDF)
需积分: 9 49 浏览量
更新于2023-05-29
评论
收藏 3.74MB PDF 举报
Beginning Functional JavaScript, 2nd Edition (True PDF)
资源详情
资源评论
资源推荐

Beginning
Functional JavaScript
Uncover the Concepts of Functional
Programming with EcmaScript 8
—
Second Edition
—
Anto Aravinth
Srikanth Machiraju

Beginning Functional
JavaScript
Uncover the Concepts of
Functional Programming
with EcmaScript 8
Second Edition
Anto Aravinth
Srikanth Machiraju

Beginning Functional JavaScript
ISBN-13 (pbk): 978-1-4842-4086-1 ISBN-13 (electronic): 978-1-4842-4087-8
https://doi.org/10.1007/978-1-4842-4087-8
Library of Congress Control Number: 2018964615
Copyright © 2018 by Anto Aravinth, Srikanth Machiraju
is work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microlms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, log os,
and images only in an editorial fashion and to the benet of the trademark owner, with no
intention of infringement of the trademark.
e use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identied as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. e publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Nikhil Karakal
Development Editor: Matthew Moodie
Coordinating Editor: Divya Modi
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media NewYork,
233 Spring Street, 6th Floor, NewYork, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.
com/rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on GitHub via the book’s product page, located at www.apress.com/.
For more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
AntoAravinth
Chennai, Tamil Nadu, India
SrikanthMachiraju
Hyderabad, Andhra Pradesh, India

iii
About the Authors �������������������������������������������������������������������������������� xi
About the Technical Reviewer �����������������������������������������������������������xiii
Acknowledgments ������������������������������������������������������������������������������xv
Introduction ��������������������������������������������������������������������������������������xvii
Table of Contents
Chapter 1: Functional Programming in Simple Terms ��������������������������1
What Is Functional Programming? Why Does It Matter? ���������������������������������������2
Referential Transparency ��������������������������������������������������������������������������������������5
Imperative, Declarative, Abstraction ����������������������������������������������������������������������7
Functional Programming Benets ������������������������������������������������������������������������8
Pure Functions ������������������������������������������������������������������������������������������������������8
Pure Functions Lead to Testable Code �������������������������������������������������������������9
Reasonable Code ������������������������������������������������������������������������������������������� 11
Parallel Code �������������������������������������������������������������������������������������������������12
Cachable ��������������������������������������������������������������������������������������������������������14
Pipelines and Composable ����������������������������������������������������������������������������16
A Pure Function Is a Mathematical Function ������������������������������������������������������17
What We Are Going to Build ��������������������������������������������������������������������������������18
Is JavaScript a Functional Programming Language? ������������������������������������������19
Summary�������������������������������������������������������������������������������������������������������������20

iv
Chapter 2: Fundamentals of JavaScript Functions �����������������������������21
ECMAScript: A Bit of History ��������������������������������������������������������������������������������22
Creating and Executing Functions ����������������������������������������������������������������������23
First Function �������������������������������������������������������������������������������������������������24
Strict Mode ����������������������������������������������������������������������������������������������������26
Return Statement Is Optional ������������������������������������������������������������������������28
Multiple Statement Functions �����������������������������������������������������������������������28
Function Arguments ��������������������������������������������������������������������������������������30
ES5 Functions Are Valid in ES6 and Above ����������������������������������������������������30
Setting Up Our Project�����������������������������������������������������������������������������������������30
Initial Setup ���������������������������������������������������������������������������������������������������31
Our First Functional Approach to the Loop Problem �������������������������������������� 33
Gist on Exports ����������������������������������������������������������������������������������������������36
Gist on Imports ����������������������������������������������������������������������������������������������36
Running the Code Using Babel-Node ������������������������������������������������������������37
Creating Script in Npm ����������������������������������������������������������������������������������38
Running the Source Code from Git ����������������������������������������������������������������39
Summary�������������������������������������������������������������������������������������������������������������40
Chapter 3: Higher Order Functions �����������������������������������������������������41
Understanding Data ��������������������������������������������������������������������������������������������42
Understanding JavaScript Data Types �����������������������������������������������������������42
Storing a Function �����������������������������������������������������������������������������������������43
Passing a Function ����������������������������������������������������������������������������������������44
Returning a Function �������������������������������������������������������������������������������������45
Table of ConTenTsTable of ConTenTs
剩余318页未读,继续阅读



















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0