> For the complete documentation index, see [llms.txt](https://javascriptuse.gitbook.io/advanced/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://javascriptuse.gitbook.io/advanced/javascript-chuyen-sau-higher-order-function-trong-javascript-phan-1-ok.md).

# \[JavaScript chuyên sâu] Higher order function trong JavaScript - phần 1 (ok)

https\://www\.youtube.com/watch?v=1harjGo3KWg\&list=PLmSai9ZRK6uyZ7L8k10pOSvQRhZbg1W4w\&index=1

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1E4Gk2ppVKb4olmnun%2Fuploads%2FQbEFsstYOyjy0YX64WWo%2FScreenshot_1.png?alt=media\&token=aa2af36b-15f6-4fa4-bdea-218d17986d04)

> **Chú ý: Nếu return function nó sẽ chạy tiếp function cái khác thì đều rừng lại**

```
function cha() {
    let x = 10;
    return function con(p) {
        x++;
        return x + p;
    }
}
const test = cha();
console.log(test(1)); // 12
console.log(test(1)); // 13
```
