-1

How to call a nested function with only a string? eg:

function oot(wha)   {
        function inn(wha)
          {
          First.innerHTML+="Inner ["+wha+"]";
          }
   oot.inn = inn;
   Second.innerHTML+="Outer ["+wha+"]";
                    }
 oot("1");  
 oot.inn("2");  //works okay
 window["oot"]("3");    //works okay
 window["oot.inn"]("4");    //<The problem, doesn't work.
 window["oot"]["inn"]("4");  //Works, thanks. 

Edited to make the code more readable, and show a solution.

IF there is no way to make this work with a single string i can probably make do, but i will leave the question unanswered for a few hours to see if there is another solution.

jobeSW
  • 39
  • 1
  • 5

1 Answers1

0

You can reference nested Objects like this:

window["oot"]["inn"]("4");

or

window.oot.inn("4")
David
  • 114
  • 5
  • They can, but the problem is that they have the string `oot.inn` and need to transform it to that. – Quentin Jul 13 '22 at 10:09