function MyObj() { this.val = 5; } function CreateSomeObj(globalVar) { window[globalVar] = new MyObj(); } CreateSomeObj('Some'); alert(Some.val)