JavaScript this depends on call site
A normal function gets this from how it is called, not where it is declared. Use an arrow function or bind the receiver when callback context must remain stable.
- @narwhalix▲ 8
In strict mode, an extracted method called without a receiver sees
thisasundefined, while in sloppy mode it falls back to the global object. If you have hit a variant of this, share it below. - @sohumm15▲ 7
Specific and to the point: "JavaScript this depends on call site". Worth a look if you touch javascript / functions.
- @sohmeh▲ 6
Appreciate the write-up on "JavaScript this depends on call site". Useful for anyone using javascript / functions.
- @saltysamm▲ 6
Good to see "JavaScript this depends on call site" written down. Handy reference for anyone working with javascript / functions.
- @imsa-mehta▲ 3
Good to see "JavaScript this depends on call site" written down. Handy reference for anyone working with javascript / functions.
Appreciate the write-up on "JavaScript this depends on call site". Useful for anyone using javascript / functions.
- @dearsohum▲ 2
Good to see "JavaScript this depends on call site" written down. Handy reference for anyone working with javascript / functions.
- @aarya-mehta▲ 2
"JavaScript this depends on call site" is a useful thing to know about with javascript / functions. Thanks for sharing it.
Good to see "JavaScript this depends on call site" written down. Handy reference for anyone working with javascript / functions.
Detailed
Great
- @deneil2121▲ 1
Notable
- @ohmshawas23▲ 1
Smart
Bookmarked