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

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -