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

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -