Created
January 24, 2019 11:05
-
-
Save KinoAR/addad280817e11fc7d4fc93d531f1f9c to your computer and use it in GitHub Desktop.
An example of a monad in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [1, 2, 3]; //The values 1, 2, 3 have been "returned"/"lifted" into the container(array) | |
const newArr = arr.map(x => x * 2);//The values are used to create new values; referred to as map | |
const value = arr[1]; // 2 -The value is taken out of the container; referred to as flatMap,bind, etc. | |
const value2 = newArr[1];//4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment