You probably have functions that aren’t equipped to accept a Maybe as an argument. And in most cases, altering functions to accept a specific container type isn’t desirable. You could use map, passing in your function, or you could “lift” your functi…
We can dot-chain our way to great success with an instance of Maybe, but there are probably cases where you need to apply the same series of transformations against different Maybes. In this lesson, we’ll look at some point-free versions of some comm…
Functions are first class in JavaScript. This means we can treat a function like any other data. This also means we can end up with a function as the wrapped value in a Maybe. The Maybe type gives us the ability to apply that wrapped function to othe…
The alt method allows us to recover from a nothing with a default Maybe, but sometimes our recovery efforts might need to enlist some logic to recover properly. In this lesson, we’ll see how we can use the coalesce method on the Maybe to recover from…
In this lesson, we’ll use a Maybe to safely operate on properties of an object that could be undefined. We’ll use our initial code as the basis for a prop utility function that can be reused with different objects and various property names. Instead…
In this lesson, we’ll create a safe function that gives us a flexible way to create Maybes based on a value and a predicate function that we supply. We’ll verify its behavior with values that satisfy the predicate, and values that do not. We can writ…
In this lesson, we’ll get started with the Maybe type. We’ll look at the underlying Just and Nothing types and create a simple utility function to create a Maybe from a value. Then we’ll see how we can apply functions to values and skip invocation fo…
1.即时函数的声明方法 即时函数(Immediate Functions)是一种特殊的JavaScript语法,可以使函数在定义后立即执行:(function () {    alert('watch out!');}()); 下面分几部来理解这种写法: 橙色部分是一个函数表达式: 天蓝色的一对括号代表立即执行它,括号里是执行这个函数需要的参数(这个例子不需要参数): 再用一对括号(就是黑色的这一对)把上面的部分包起来. 黑色这一对括号可以让人明白这个表达式得到的是函数的返回值,而不是函数对象.…
The immediate function pattern is a syntax that enables you to execute a function as soon as it is defined. (function () { alert('watch out!'); }());  • You define a function using a function expression. (A function declaration won’t work.) • You add…
Once we’re using Maybes throughout our code, it stands to reason that at some point we’ll get a Maybe and want to continue applying transformations. We might get a Nothing and want to perform those same transformations on some default value. In this…