Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
iliakan committed May 31, 2019
1 parent 9f4b8a5 commit 2be1b5b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 1-js/04-object-basics/04-object-methods/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ admin['f'](); // Admin (dot or square brackets access the method – doesn't mat

The rule is simple: if `obj.f()` is called, then `this` is `obj` during the call of `f`. So it's either `user` or `admin` in the example above.

```smart header="Calling without an object: `this=undefined`"
````smart header="Calling without an object: `this=undefined`"
We can even call the function without an object at all:

```js run
Expand All @@ -220,7 +220,7 @@ In this case `this` is `undefined` in strict mode. If we try to access `this.nam
In non-strict mode the value of `this` in such case will be the *global object* (`window` in a browser, we'll get to it later in the chapter [](info:global-object)). This is a historical behavior that `"use strict"` fixes.

Usually such call is an programming error. If there's `this` inside a function, it expects to be called in an object context.
```
````
```smart header="The consequences of unbound `this`"
If you come from another programming language, then you are probably used to the idea of a "bound `this`", where methods defined in an object always have `this` referencing that object.
Expand Down

0 comments on commit 2be1b5b

Please sign in to comment.