Nested Functions


Nested Functions

  • We can declare a function inside another function, such type of functions are called Nested functions.
In the above example inner() function is local to outer() function and hence it is not possible to call directly from outside of outer() function.


  • A function can return another function. 

Q. What is the differenece between the following lines? 

  • f1=outer
  • f1=outer()
  • In the first case for the outer() function we are providing another name f1(function aliasing).
  • But in the second case we calling outer() function,which returns inner function.For that inner function() we are providing another name f1
Note: We can pass function as argument to another function.


  • filter(function,sequence)         
  • map(function,sequence)         
  • reduce(function,sequence) 

Post a Comment

Post a Comment (0)