JS Startup

Challenges, Tips & Tricks & Tutorials

JavaScript Quiz – Is the calling function inside function are equal

JavaScript Quiz – Is the calling function inside function are equal

Calling function inside function –

Calling function inside a function actually a calling the same function which you declare or their is another function which you declare.

As, calling other function inside one’s function. You are already aware of it. But when you call same function inside a same function body then it leads to a recursive function.

If you want to know more JavaScript Recursive Function

JavaScript Question

First, we create a variable foo using the let keyword. And create a function foo and define their body and assign it foo variable.

Now, in the foo function body, we are returning a comparison of the foo variable. And foo is comparing with triple equal `===` with own self.

At last , we create an another variable result using let. And assign a foo() method with calling itself.

Finally, You need to guess that what should be the output of result variable.

Answer – true

Click To Run code


Now you are thinking, why the answer is true. And can we call the function inside a function & we call foo without the method? Then how can? it returns true.

So, Firstly you can see we have a foo variable and foo function also. But at last, we are assigning that foo function to foo variable.

That kind of function assignment is called Function expression

There is one more scenario that occurs when we call a function without method means as we did it in a function body. That time it does not return the function value but it returns the whole function body.

Like this –

function foo() {
  return foo === foo;

So, when we compare both of foo together they are same and return true.

Check out our other javascript quiz – 

  1. JavaScript Quiz – What actually negative infinity value returns
  2. JS Quiz – What really the array values method return
  3. JavaScript Quiz – Does nested array reference removed by spread syntax
  4. JavaScipt Quiz – What is the length of String Split Method


To participate in our javascript quiz or challenges, tutorial, tips & tricks make sure to join our jsstartup newsletter. So, you can able to participate in our daily challenges & learn the javascript concept.

And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page

If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top
Share via
Copy link