I understand that previous questions have concluded that JS is a pass-by-value language and onject falues can not be modified by using a function to declare their new value. However, I would like to see how COULD it be possible. For example I have the following code:
var oneBoolean = true;
var oneInput = undefined;
if (oneInput === undefined){
oneBoolean = false;
}
I understand that this doesn't work... But how COULD I get this functionality to work? I know that the input value is indeed undefined, yet I need that to be recognized and change the input value. I know that array objects can be modified, but is there any way possible for me to assign the appropriate Boolean value inside of this if statement? Do I need to assign these variables inside of the if statement as so:
var oneInput = document.getElementById("someInput");
if (oneInput === undefined){
var oneBoolean = false;
} else{
var oneBoolean = true;
}
I don't believe that this would work either. Any help or pointers would be appreciated.
Aucun commentaire:
Enregistrer un commentaire