P.S.: I am not asking how to pass a function to a function! I am asking how to add a argument after passing a function.
I want to pass functionA as a variable to functionB, and add a extra object to functionA inside functionB. How can I do this?
function functionA() {
console.log( arguments );
}
function functionB( fn ) {
fn( {
c : 'extra object',
});
}
functionB( function() {
functionA( {
a : 'foo',
b : 'bar',
})
});
this is the result:
{ '0': { a: 'foo', b: 'bar' } }
but what I want is:
{ '0': { a: 'foo', b: 'bar', c: 'extra object' } }