Closure

According to Wikipedia, a Clojure ( /ˈkloʊʒɜːr/, like “closure”) is a dialect of the Lisp programming language. Clojure is a general-purpose programming language with an emphasis on functional programming. It runs on the Java virtual machineand the Common Language Runtime. Like other Lisps, Clojure treats code as data and has a macro system. The current development process is community-driven, overseen by Rich Hickey as its benevolent dictator for life (BDFL).

But, to be honest we don’t really need to know that.

Here’s the simple definition: Closures are functions that “remember” the environment in which they were created.

const cat = () => {
let name = 'Bacon'

const hello = () => {
console.log(`Hello ${name}`)
}
    hello()
}
cat() // 'Hello Bacon'

The variable name is available on both, the cat and hello function.

Conclusion

There’s closures everywhere and they are really useful in functional programming or using different patterns of modules.

Like what you read? Give Maxime Beaudoin a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.