I'm trying to push all function parameters to array, where one parameter is function and i can't do this, because after pushing function to array i have null in this place I have following problem, i have:
var someFunction1 = function(someValue, callback)
{
// I CAN DO THIS, CALL HERE CALLBACK
callback();
// OR PASS CALLBACK TO ANOTHER FUNCTION AND CALL
// BUT WHEN I'M TRYING THIS:
var someArray = []; // OR new Array() ...
someArray.push(someValue);
someArray.push(callback);
console.log(someArray); // <--- THIS WILL GIVE ME ["EXAMPLE",null] to console
}
var someFunction2 = function()
{
var callbackFunction = function()
{
console.log("SOME TEXT");
}
someFunction1("EXAMPLE", callbackFunction);
}
Why i cant push this callback function into array??
Please help :)
I chceck this problem on IOS(PhoneGap Project) now and when i try:
var array = [];
array.push(function(){console.log("TEST");});
console.log(array);
then i get result [null] -> but this work on JSFiddle (also on OSX Safari and IOS Safari) :(