Matrix Matrix - 1 year ago 108
Javascript Question

How define function in javascript in global context inside a function?

context = this
function test() {
(function(cmd) {
}).call(context, 'function foo(){}');

foo(); // => ReferenceError: foo is not defined

how can I define a global function inside a function ? (using nodeJS)

Answer Source

A typical way to access the global object is calling a yielded value, e.g. from the comma operator.

function a() {
  (0, function () { = function () { console.log("works"); };

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download