Skip to content

Commit aca5590

Browse files
committed
exec: how-can-closures-be-used-to-create-private-variables
1 parent ec00257 commit aca5590

File tree

1 file changed

+2
-2
lines changed
  • questions/how-can-closures-be-used-to-create-private-variables

1 file changed

+2
-2
lines changed

questions/how-can-closures-be-used-to-create-private-variables/en-US.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: How can closures be used to create private variables?
66

77
Closures in JavaScript can be used to create private variables by defining a function within another function. The inner function has access to the outer function's variables, but those variables are not accessible from outside the outer function. This allows you to encapsulate and protect the variables from being accessed or modified directly.
88

9-
```js
9+
```js live
1010
function createCounter() {
1111
let count = 0; // private variable
1212

@@ -51,7 +51,7 @@ To create private variables using closures, you can define a function that retur
5151

5252
Here's a detailed example to illustrate how closures can be used to create private variables:
5353

54-
```js
54+
```js live
5555
function createCounter() {
5656
let count = 0; // private variable
5757

0 commit comments

Comments
 (0)