"use strict"; var name = "foo"; var priv = "Private!"; var customAction = function(pub) { var internal = "internal! " + Date.now(); var theRest = "Private: " + priv + ", Public: " + pub + ", Internal:" + internal; alert(theRest) } var func = new Function("action", "return function " + name + "(public){ action(public) };")(customAction); //we call it //We will see both the public argument and the private variable func("Public!");