javascript - Passing a function with parameters -


i want pass function parameters function without evaluating it.

this method doesn't work:

function first (id) {...}  function second (func) {     func(); }   second(first(id));  

this method can't use because number of parameters not same:

function first (id) {...}  function second (func, id) {     func(id); }  second(first, someid); 

you can use #bind partial application:

second( first.bind(null, id) ) 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -