Trying to simplify some Javascript with closures -


I'm trying to simplify some JS code which uses the closor, but I'm not getting anywhere (Possibly because I'm not cloaking)

I have some code that looks like this:

  var server = http.create server (function (request, Response) {var httpmethods = {"GET"}: function () {alert ('GET')}, "PUT": function () {warning ('PUT')}}}}  

And I'm trying to simplify it like this:

Unfortunately for doing this Looks like this ... - What am I doing wrong? - Is it possible to do it? - How?

TIA

- MV

If you do not set the object properly, you can name the function names. Area rather than put the name of the names of strings - or something like this:

  var server = http.createServer (function (request response) {}); Var httpmethods = {get: function () {alertGET ()}, put: function () {alertPUT ()}}; Function Alert (GET) {Warning ('Called' '); } Function alerts () () (warning ('called put');} Httpmethods.get () httpmethods.put ()  

In this way you define the methods inside the object , But are not sure other stuff you have (http.createServer ...)?


Comments