JavaScript Closure and Arrow functions
DescriptionI defined createCounter which can take a function as a parameter, then an arrow function that returns n and its increments.Key Concepts
Closure
Highe
# Description
I defined createCounter which can take a function as a parameter, then an arrow function that returns n and its increments.

# Key Concepts
- Closure
- Higher-order functions
- Anonymous functions
- Arrow functions
- Increment operator (n++)
- State persistence
- Encapsulation


# Code
```javascript []
function createCounter(n) {
    // This is a Higher-Order Function because it returns another function.
    return () => {
        // The returned function is an Anonymous Function (no explicit name).
        // 'n' is part of a Closure, so its value is remembered between calls.
        // The Increment Operator (n++) returns the current value of 'n' and then increments it.
        return n++;
    };
}
```
['JavaScript']