You could use apply:
fun.apply(thisArg[, argsArray]):
- thisArg:
The value of
this provided for the call to fun. Note that this may not be the actual value seen by the method: if the method is a
function in non-strict mode code, null and undefined will be
replaced with the global object, and primitive values will be boxed.
- argsArray:
An array-like object, specifying the arguments with which
fun should be called, or null or undefined if no arguments should be
provided to the function.
Be aware that, if you don't use strict mode, declaring variables without var makes them global variables, so you can use it as a property of window:
var1 = "YayanObject";
var2 = [1,"2","Hello world"];
window[var1].apply(null, var2); /* Instead of `null` you can use the object
you want to become `this` */
But I recommend you to to store in var1 a reference to your constructor instead of an string:
var var1 = YayanObject,
var2 = [1,"2","Hello world"];
var1.apply(null, var2);
this.function =...