When I call function hi()()
with double brackets the function displays hi
output and it will also give error saying, that hi
is not functi
The return value of this function is a string which is not a callable object.
function hi()
{
document.write("hi");
return "hello"; // <-- returned value
}
But if you want to call this function multiple times you can use a for-loop or some things else.
Example of hi()():
function hi(){
return function(){ // this anonymous function is a closure for hi function
alert('some things')
}
}
JS Fiddle: here
If you want to call hello
function immediately after hi
try this:
function hi()
{
document.write("hi");
return hello; //<-- no quote needed
// In this context hello is function object not a string
}