0
how can i call a function inside another function in javascript?
i mean how to call it in an event like click or ...
7 odpowiedzi
+ 2
If you mean how to call an internal function from outside the external function this generally cannot be done without creating a function reference within the external function that points to the internal function. The external function then must be called at least once prior to attempting to use this internal function reference so that it is assigned, otherwise it will not exist when called.
function outer() {
alert("outer function called");
function inner() {
alert("inner function called");
}
outer.inner = inner; // create a reference to the inner function
}
outer(); // This calls the outer function
// inner(); // this won't work
// outer().inner(); // This will call the outer function, but not the inner.
outer.inner(); // This calls the inner function, but only after the outer function has been called at least once to create the reference to the the inner function.
+ 3
you can call all public functions from anywhere but you should be carefull about return types, unfinite loops and private/protected calls
ways to call functions:
- functionName ();
- funtionName ( varA, varB);
etc.
+ 2
don't forget ; (semicolumn)
+ 2
please check this see example https://code.sololearn.com/WQ43MoS8WwY2/?ref=app
+ 1
by calling the name of the function inside it, ex: function myFunc() {doSomething();}
0
is it possible to this <input type=button name="doit" onclick="drawr(); draw(); drawp();">reveal the truth</input>
do you mean like this
0
thank you both ,both of this codes working perfectly