I understand where you’re going with your thought process, however there are a few different ways that you could accomplish what you’re attempting. Please see below for further details.
First off, Functions and Variables are very different in terms of how they’re used in programming.
var variable1 = ///value
function Object1 (Param1, Param2, ...) { ... }
The best way to use an if function would be to use a preset variable to distinguish whether or not Object1 should be run. This can be done in a few ways:
var boolean = false; ///Initializer
function Object1() { ... } ///Initializer
if (boolean == true){ Object1(); }; ///If statement CALLS Object1
or
var boolean = false;
function Object1( Param1 ) { ///If statement INSIDE Object1
if (Param1 == true) { ... }
}
Object1(boolean);
Both of these could be used for various purposes but the easiest way would be to simply call the object IF a certain condition applies. This would best be measured with a variable for obvious reasons.
I hope this helps!
-lolman
#-EDIT-
If you’re wanting to get a value that’s returned from an object that’s slightly more complicated.
function Obj(){ //Object initializaiton
...
return true;
}
if (Obj() == true){ ... };
Obj(); //Object Call
@toplearner basically hit it on the head but I misunderstood the question. Again I hope this helps!