So I created a function like this,
var functionName = function(arg1) { //code logic here; }
At the same time, I need this function to work
You could set the prototype of the function.
prototype
function functionName(arg1) { //code logic here; } var myObj = { x: 3, y: 4 }; functionName.prototype = myObj; var obj = new functionName(); console.log(obj.x, obj.y); // will output 3, 4