Question #691

What is a closure?

A closure, unlike a plain function, allows a function to access variables captured through the closure’s copies of their values or references, even when the function is invoked outside their scope. Looking at the code below:

def outerFunction(text): 
    text = text 
    def innerFunction(): 
    return innerFunction

myFunction = outerFunction('hello') 

will return:


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵