javascript - Create a simpler way of nesting functions -
i'm looking lower overhead on code this
foo(bar(baz("hello"))) // function hell   ideally this
var fbb = bind(foo, bar, baz) foo("hello")   does exist? native or library?
i looked through underscore , bind.
underscore has compose function want:
var composite = _.compose(foo, bar, baz);  composite('hello');   function foo(a1){    return 'foo' + a1;  }		    function bar(a2){    return 'bar' + a2;  }    function baz(a3){    return 'baz' + a3;  }    alert(foo(bar(baz("hello"))));    var composite = _.compose(foo, bar, baz);    alert( composite('hello') );  <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>  
Comments
Post a Comment