質問 1
Explain the concept of closures in JavaScript.
Closures allow a function to access variables from its outer (enclosing) scope even after the outer function has finished executing. They help in creating private variables and methods.
Example:
```javascript
function outer() {
let x = 10;
function inner() {
console.log(x);
}
return inner;
}
const closureExample = outer();
closureExample(); // Outputs 10
```
復習用に保存
復習用に保存
この項目をブックマークに追加したり、難しい内容としてマークしたり、復習セットに入れたりできます。
役に立ちましたか?
コメントを追加
コメントを見る