Javascript:
var myfunc = function(foo, bar) {
foo.thing();
bar.stuff();
};
if foo and bar will always be objects with functions thing and stuff, but foo and bar have not been declared as global variables because they could be any of a number of objects meeting this criteria, what is the proper way to declare myfunc?
And what if myfunc is a member of another object?
EDIT Less generic case (node.js/express):
var express = require("express");
app = express();
app.set("views", __dirname + "html");
var myfunc = function(req, res) {
res.render("file.html");
};
app.get("/", function(req, res) {
myfunc(req, res);
});
// ^ OR v Tried both, but it doesn't get this far
app.get("/", myfunc(req, res));
app.listen(8080);
Errors state in var myfunc = function(req, res) { that res.render() is undefined.
app.get("/", myfunc);andapp.getwill invoke your function with the 2 parameters.