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
...
 •  0 comments  •  flag
Share on Twitter
Published on May 22, 2019 22:39

May 20, 2019

Discover Functional JavaScript

Discover Functional JavaScript was named one of the best new Functional Programming books by BookAuthority !

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...

 •  0 comments  •  flag
Share on Twitter
Published on May 20, 2019 10:31

An introduction to Functional JavaScript

Discover Functional JavaScript was named one of the best new Functional Programming books by BookAuthority ! Photo by Justin Luebke on Unsplash

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...

 •  0 comments  •  flag
Share on Twitter
Published on May 20, 2019 10:31

April 1, 2019

An introduction to scope in JavaScript

Discover Functional JavaScript was named one of the best new Functional Programming books by BookAuthority!

Continue reading on Medium

 •  0 comments  •  flag
Share on Twitter
Published on April 01, 2019 11:01

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.

 •  0 comments  •  flag
Share on Twitter
Published on March 14, 2019 10:55

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.

 •  0 comments  •  flag
Share on Twitter
Published on March 06, 2019 23:57

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.

Photo by Sergiu Vălenaș on Unsplash

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.

Reducer

A reducer is a pure function that takes state and action as parameters and returns...

 •  0 comments  •  flag
Share on Twitter
Published on February 12, 2019 15:16

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.

 •  0 comments  •  flag
Share on Twitter
Published on February 03, 2019 05:47

February 1, 2019

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:

Continue reading on The Startup

 •  0 comments  •  flag
Share on Twitter
Published on January 31, 2019 10:23