This commit is contained in:
Ilya Kantor 2019-08-27 10:46:45 +03:00
parent 5c8d24a582
commit 2d3f7cc7ce

View file

@ -148,10 +148,10 @@ function BigUser() {
this.name = "John";
return { name: "Godzilla" }; // <-- returns an object
return { name: "Godzilla" }; // <-- returns this object
}
alert( new BigUser().name ); // Godzilla, got that object ^^
alert( new BigUser().name ); // Godzilla, got that object
```
And here's an example with an empty `return` (or we could place a primitive after it, doesn't matter):
@ -161,7 +161,7 @@ function SmallUser() {
this.name = "John";
return; // finishes the execution, returns this
return; // <-- returns this
}
alert( new SmallUser().name ); // John