You pass it as a function argument.
function needs_to_make_a_car(car_maker, road) {
var car = car_maker()
car.drive_on(road)
}
To which you would probably reply: "But that's exactly what FactoryFactory/DependencyInjection/... pattern is!"To which we would reply: "Exactly, which are just fancy words for the re-and-re-discovered concept of functional programming."