mercredi 9 septembre 2015

Javascript, How to send a placeholder variable to a function?

It would seem I failed to ask my question correctly as it is getting heavily down-voted. I'll try to rephrase it.

I have a function with an if-statement. When this if-statement is triggered I want to tell another function to clear out its array.

function firstFunction(){
if(!$myCheckBox.is(':checked')){
    secondFunction(myArray.length = 0);
    }
}

function secondFunction(myArray){
if(myArray.length == 0){
    //Do something
    }
}

Now this problem was solved with the help of another member (#Peter Kalef ' DidiSoft), by simply adding a new array in firstFunction and then passing it on to the secondFunction.

function firstFunction(){
if(!$myCheckBox.is(':checked')){
    var myArray = [];
    myArray.length = 0;
    secondFunction(myArray);
    }
}

Aucun commentaire:

Enregistrer un commentaire