Home > Blockchain >  NodeJs - Return a dot function from within a function
NodeJs - Return a dot function from within a function

Time:10-07

So the basic idea is I am working on converting some java code to run in NodeJS. I have a call GraphicsEnvironment.getLocalGraphicsEnvironment that returns a String. For testing, I've tried:

function GraphicsEnvironment()
{
  function getLocalGraphicsEnvironment(value)
  {
    alert(value);
    return getLocalGraphicsEnvironment(value);
  };
};

But this still returns:

GraphicsEnvironment.getLocalGraphicsEnvironment is not a function.

What is the simplest way to do this so the code can remain in a single file?

CodePudding user response:

Write this as an Object so that you can retrieve the function needed

const GraphicsEnvironment = {
getLocalGraphicsEnvironment: function (value)
  {
    alert(value);
    return this.getLocalGraphicsEnvironment(value);
  }
}
  • Related