Functional Programming

functional programming is a paradigm

programming paradigm where functions are king impertive Programming, OOPrograming, Coding style Mindset Sexy trend & latest trend

Why functional programming? Is safer Easier to debug and to maintain established community

What it will do? Impertative programming lazy example:

var name = "Srini"; var greet = "Hi I'm";

console.log(greet + name);

functional programming:

// Below is a pure function, since its not dependent on any other varialbe but passed input. function greet(name){ return "Hi I'm " + name; }


have to write pure functions, just pass input and get the output

Write Pure Fnction function greet(name){ return "Hi I'm " + name; }

Use as much as higer order function

Use in build library functions such as filter, sort, map, reduce avoid mutation var rooms = ["H1", "H2", "H3"]; room[2] = "H3";

immutable var rooms = ["H1", "H2", "H3"];

var newRooms ={ if(room == "H3"){return "H4"} else { return room} });

Persistance data structure

Structral sharing -

immutable data structure Mori, Immutablejs