> For the complete documentation index, see [llms.txt](https://notes.lirenxn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.lirenxn.com/featured/thoughts/javascript-this.md).

# Javascript this

### Interpretation on `this` <a href="#interpretation-on-this" id="interpretation-on-this"></a>

The binding `this` in javascript can be interpretated as, if there is a `this` pointer in function:

* If you want to passing function around, or ensure using `this` in current context, **MUST** use arrow function `() => {}`;
* If you want to use `this` in some other context, late binding, use `function(){}`

To make things even easier, rules **(almost a silver bullet)** can be:

**ONLY** use `function(){}`, if you want to use a late bound `this`.
