https://github.com/azu/what-is-this
What value is `this` in Strict, Script, or Module?
https://github.com/azu/what-is-this
ecmascript javascript spec this
Last synced: about 1 year ago
JSON representation
What value is `this` in Strict, Script, or Module?
- Host: GitHub
- URL: https://github.com/azu/what-is-this
- Owner: azu
- License: mit
- Created: 2017-12-02T10:05:19.000Z (over 8 years ago)
- Default Branch: gh-pages
- Last Pushed: 2023-05-28T01:27:14.000Z (about 3 years ago)
- Last Synced: 2024-10-05T12:43:39.944Z (over 1 year ago)
- Topics: ecmascript, javascript, spec, this
- Language: JavaScript
- Homepage: https://azu.github.io/what-is-this/
- Size: 88.9 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# what-is-this
What value is `this` in Strict, Script, or Module?
## Comparison Table
Open following URL:
- Function:
- Method:
## :bug: Bug
- V8
- [791334 - `this` in top level Arrow Function in Module Context should be `undefined` - chromium - Monorail](https://bugs.chromium.org/p/chromium/issues/detail?id=791334 "791334 - `this` in top level Arrow Function in Module Context should be `undefined` - chromium - Monorail")
## :memo: Specification
- Set `[[ThisValue]]`
- https://tc39.github.io/ecma262/#sec-evaluatecall
- https://tc39.github.io/ecma262/#sec-call
- https://tc39.github.io/ecma262/#sec-ecmascript-function-objects-call-thisargument-argumentslist
- https://tc39.github.io/ecma262/#sec-ordinarycallbindthis
- Lookup `[[ThisValue]]`
- https://tc39.github.io/ecma262/#sec-getthisenvironment
### Script(Global) Environment
- `[[ThisValue]]`: global
### Module Environment
- `[[ThisValue]]`: undefiled
### Function call
- Depended on call context
### Arrow Function call
- Arrow Function don't bind `[[ThisValue]]`
- Depended on enclosing environment
- https://tc39.github.io/ecma262/#sec-ordinarycallbindthis
- https://tc39.github.io/ecma262/#sec-arrow-function-definitions-runtime-semantics-evaluation
- https://esdiscuss.org/topic/clarification-regarding-top-level-arrow-functions-and-this-arguments
## Changelog
See [Releases page](https://github.com/azu/what-is-this/releases).
## Running tests
Install devDependencies and Run `npm test`:
npm i -d && npm test
## Contributing
Pull requests and stars are always welcome.
For bugs and feature requests, [please create an issue](https://github.com/azu/what-is-this/issues).
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
## Author
- [github/azu](https://github.com/azu)
- [twitter/azu_re](https://twitter.com/azu_re)
## License
MIT © azu