• Complain

Dan Mantyla - JavaScript: Functional Programming for JavaScript Developers

Here you can read online Dan Mantyla - JavaScript: Functional Programming for JavaScript Developers full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2016, publisher: Packt Publishing, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Dan Mantyla JavaScript: Functional Programming for JavaScript Developers

JavaScript: Functional Programming for JavaScript Developers: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "JavaScript: Functional Programming for JavaScript Developers" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

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 its effective, and how its used in JavaScript
  • Understand and optimize JavaScripts 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. Its 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 JavaScripts 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 likeFunctions and Closures, Runtime debugging techniques, project layout, events and DOM processing, build tools, Object-oriented patterns, isomorphismeverything 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. Youll 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.

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 purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Dan Mantyla: author's other books


Who wrote JavaScript: Functional Programming for JavaScript Developers? Find out the surname, the name of the author of the book and a list of all author's works by series.

JavaScript: Functional Programming for JavaScript Developers — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "JavaScript: Functional Programming for JavaScript Developers" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Appendix A. Common Functions for Functional Programming in JavaScript

This Appendix covers common functions for functional programming in JavaScript:

  • Array Functions:
    var flatten = function(arrays) { return arrays.reduce( function(p,n){ return p.concat(n); });};var invert = function(arr) { return arr.map(function(x, i, a) { return a[a.length - (i+1)]; });};
  • Binding Functions:
    var bind = Function.prototype.call.bind(Function.prototype.bind);var call = bind(Function.prototype.call, Function.prototype.call);var apply = bind(Function.prototype.call, Function.prototype.apply);
  • Category Theory:
    var checkTypes = function( typeSafeties ) { arrayOf(func)(arr(typeSafeties)); var argLength = typeSafeties.length; return function(args) { arr(args); if (args.length != argLength) { throw new TypeError('Expected '+ argLength + ' arguments'); } var results = []; for (var i=0; i
  • Composition:
    Function.prototype.compose = function(prevFunc) { var nextFunc = this; return function() { return nextFunc.call(this,prevFunc.apply(this,arguments)); };};Function.prototype.sequence = function(prevFunc) { var nextFunc = this; return function() { return prevFunc.call(this,nextFunc.apply(this,arguments)); };};
  • Currying:
    Function.prototype.curry = function (numArgs) { var func = this; numArgs = numArgs || func.length; // recursively acquire the arguments function subCurry(prev) { return function (arg) { var args = prev.concat(arg); if (args.length < numArgs) { // recursive case: we still need more args return subCurry(args); } else { // base case: apply the function return func.apply(this, args); } }; }; return subCurry([]);};
  • Functors:
    // map :: (a -> b) -> [a] -> [b]var map = function(f, a) { return arr(a).map(func(f));}// strmap :: (str -> str) -> str -> strvar strmap = function(f, s) { return str(s).split('').map(func(f)).join('');}// fcompose :: (a -> b)* -> (a -> b)var fcompose = function() { var funcs = arrayOf(func)(arguments); return function() { var argsOfFuncs = arguments; for (var i = funcs.length; i > 0; i -= 1) { argsOfFuncs = [funcs[i].apply(this, args)]; } return args[0]; };};
  • Lenses:
    var lens = function(get, set) { var f = function (a) {return get(a)}; f.get = function (a) {return get(a)}; f.set = set; f.mod = function (f, a) {return set(a, f(get(a)))}; return f;};// usage:var first = lens( function (a) { return arr(a)[0]; }, // get function (a, b) { return [b].concat(arr(a).slice(1)); } // set);
  • Maybes:
    var Maybe = function(){}; Maybe.prototype.orElse = function(y) { if (this instanceof Just) { return this.x; } else { return y; }};var None = function(){}; None.prototype = Object.create(Maybe.prototype);None.prototype.toString = function(){return 'None';};var none = function(){return new None()};// and the Just instance, a wrapper for an object with a valuevar Just = function(x){return this.x = x;};Just.prototype = Object.create(Maybe.prototype);Just.prototype.toString = function(){return "Just "+this.x;};var just = function(x) {return new Just(x)};var maybe = function(m){ if (m instanceof None) { return m; } else if (m instanceof Just) { return just(m.x); } else { throw new TypeError("Error: Just or None expected, " + m.toString() + " given."); }};var maybeOf = function(f){ return function(m) { if (m instanceof None) { return m; } else if (m instanceof Just) { return just(f(m.x)); } else { throw new TypeError("Error: Just or None expected, " + m.toString() + " given."); } };};
  • Mixins:
    Object.prototype.plusMixin = function(mixin) { var newObj = this; newObj.prototype = Object.create(this.prototype); newObj.prototype.constructor = newObj; for (var prop in mixin) { if (mixin.hasOwnProperty(prop)) { newObj.prototype[prop] = mixin[prop]; } } return newObj;};
  • Partial Application:
    function bindFirstArg(func, a) { return function(b) { return func(a, b); };};Function.prototype.partialApply = function(){ var func = this; var args = Array.prototype.slice.call(arguments); return function(){ return func.apply(this, args.concat( Array.prototype.slice.call(arguments) )); };};Function.prototype.partialApplyRight = function(){ var func = this; var args = Array.prototype.slice.call(arguments); return function(){ return func.apply( this, Array.protype.slice.call(arguments, 0) .concat(args)); };};
  • Trampolining:
    var trampoline = function(f) { while (f && f instanceof Function) { f = f.apply(f.context, f.args); } return f;};var thunk = function (fn) { return function() { var args = Array.prototype.slice.apply(arguments); return function() { return fn.apply(this, args); }; };};
  • Type Safeties:
    var typeOf = function(type) { return function(x) { if (typeof x === type) { return x; } else { throw new TypeError("Error: "+type+" expected, "+typeof x+" given."); } };};var str = typeOf('string'), num = typeOf('number'), func = typeOf('function'), bool = typeOf('boolean');var objectTypeOf = function(name) { return function(o) { if (Object.prototype.toString.call(o) === "[object "+name+"]") { return o; } else { throw new TypeError("Error: '+name+' expected, something else given."); } };};var obj = objectTypeOf('Object');var arr = objectTypeOf('Array');var date = objectTypeOf('Date');var div = objectTypeOf('HTMLDivElement');// arrayOf :: (a -> b) -> ([a] -> [b])var arrayOf = function(f) { return function(a) { return map(func(f), arr(a)); }};
  • Y-combinator:
    var Y = function(F) { return (function (f) { return f(f); }(function (f) { return F(function (x) { return f(f)(x); }); }));};// Memoizing Y-Combinator:var Ymem = function(F, cache) { if (!cache) { cache = {} ; // Create a new cache. } return function(arg) { if (cache[arg]) { // Answer in cache return cache[arg] ; } // else compute the answer var answer = (F(function(n){ return (Ymem(F,cache))(n); }))(arg); // Compute the answer. cache[arg] = answer; // Cache the answer. return answer; };};
Appendix B. Glossary of Terms

This appendix covers some of the important terms that are used in this book:

  • Anonymous function : A function that has no name and is not bound to any variables. It is also known as a Lambda Expression.
  • Callback : A function that can be passed to another function to be used in a later event.
  • Category : In terms of Category Theory, a category is a collection of objects of the same type. In JavaScript, a category can be an array or object that contains objects that are all explicitly declared as numbers, strings, Booleans, dates, objects, and so on.
  • Category Theory : A concept that organizes mathematical structures into collections of objects and operations on those objects. The data types and functions used in computer programs form the categories used in this book.
  • Closure : An environment such that functions defined within it can access local variables that are not available outside it.
  • Coupling : The degree to which each program module relies on each of the other modules. Functional programming reduces the amount of coupling within a program.
  • Currying : The process of transforming a function with many arguments into a function with one argument that returns another function that can take more arguments, as needed. Formally, a function with N arguments can be transformed into a function chain of N functions, each with only one argument.
  • Declarative programming : A programming style that expresses the computational logic required to solve the problem. The computer is told what the problem is rather than the procedure required to solve it.
  • Endofunctor
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «JavaScript: Functional Programming for JavaScript Developers»

Look at similar books to JavaScript: Functional Programming for JavaScript Developers. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «JavaScript: Functional Programming for JavaScript Developers»

Discussion, reviews of the book JavaScript: Functional Programming for JavaScript Developers and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.