About javascript function closure

About javascript function closure

Dear all:

I try to improve the ability of javascript, and meet a problem about closure, like following example:

  1.  function Y(f) {
  2.   return ((function(x) {
  3. return f(function(v) {
  4.   return x(x)(v);
  5. });
  6.   })(function(x) {
  7. return f(function(v) {
  8.   return x(x)(v);
  9. });
  10.   }));
  11. }

  12. var factorial = Y(function(fac) {
  13.   return function(n) {
  14. return (n == 0 ? 1 : n * fac(n - 1));
  15.   }
  16. });

  17. console.log( factorial(5));

I don't know how the function Y(f) works. I have add console.log to see the detail , but still confuse
about that, so I put some codes in jsfiddle,  https://jsfiddle.net/abramhum/6uqpd28s/
and try to fill in the function by myself, but I found I don't know how to create this function and 
make it work well. Is any one know the exact answer for that, and how to make that, thanks a lot.