Cristian Salcescu's Blog, page 19
May 22, 2019
Hi!
Hi!
Good remark! It turns out that map() calls the mapping function with more arguments than we expect. The first argument is the element in the array and the second one is the element index. Take a look at the toInt() mapping function:
const numbers = ['1','2','3','4','5','6'];function toInt(value, index){console.log(`value: ${value} index: ${index}`);
return parseInt(value, index);
}console.log(numbers.map(toInt));
//value: 1 index: 0
//value: 2 index: 1
//value: 3 index: 2
//value: 4 index: 3
...
May 20, 2019
Discover Functional JavaScript

The Discover Functional JavaScript is now ready in both paperback and Kindle formats.
This book tries to give practical examples of the core functional concepts. I think that if we master the fundamentals then it will be easier to handle more complex situations. And this is what this book is for.
I looked into a deeper understanding of pure functions other than that they are great. If they ar...
An introduction to Functional JavaScript


Hey everybody! Ive written a book called Discover Functional JavaScript, and its now ready in both paperback and Kindle formats.
After publishing several articles on Functional Programming in JavaScript, at some point, I realized I have enough material to think about a book. So, I started from my previous writings, filled in the missing parts and created...
April 1, 2019
An introduction to scope in JavaScript
Discover Functional JavaScript was named one of the best new Functional Programming books by BookAuthority!
March 14, 2019
Hi! Thanks for your feedback!
Hi! Thanks for your feedback! Part of the code samples are available at this repository https://github.com/cristi-salcescu/discover-functional-javascript. In regards to the rest of the code I will encourage developers to write it themselves.
I will update the book with this information.
I hope the book is useful to you.

March 6, 2019
Hi! I made a jsperf test comparing functional closure generators with chaining array methods.
Hi! I made a jsperf test comparing functional closure generators with chaining array methods. I processed a collection of 100 000 to-dos and took the first 100. You can take a look.

February 12, 2019
How to create a Redux reducer by convention
Learn functional React, in a project-based way, with Functional Architecture with React and Redux.

Redux is a very popular state management library. It simplifies the original Flux architecture by combining all stores and the dispatcher in a single store object.
Redux promotes the use of functional programming for managing state. It introduces the reducer function concept.
ReducerA reducer is a pure function that takes state and action as parameters and returns...
February 3, 2019
Take in consideration that books stores a List immutable data structure from Immutable.js.
Take in consideration that books stores a List immutable data structure from Immutable.js. Using push() on books will result in a new List. Any update on the List immutable collection results in a new List.
If books would have stored the JavaScript array data structure ([]), then yes push() would be impure, making the whole function impure.

February 1, 2019
OK. Good point. I updated the article.
OK. Good point. I updated the article.

January 31, 2019
An introduction to the Flux architectural pattern
Flux is an architectural pattern proposed by Facebook for building SPAs. It suggests to split the application into the following parts: