fixes
This commit is contained in:
parent
eeee9fedf7
commit
7697f95e24
4 changed files with 41 additions and 38 deletions
|
@ -15,13 +15,13 @@ The error message in most browsers does not give understanding what went wrong.
|
|||
|
||||
**The error appears because a semicolon is missing after `user = {...}`.**
|
||||
|
||||
JavaScript does not assume a semicolon before a bracket `(user.go)()`, so it reads the code like:
|
||||
JavaScript does not auto-insert a semicolon before a bracket `(user.go)()`, so it reads the code like:
|
||||
|
||||
```js no-beautify
|
||||
let user = { go:... }(user.go)()
|
||||
```
|
||||
|
||||
Then we can also see that such a joint expression is syntactically a call of the object `{ go: ... }` as a function with the argument `(user.go)`. And that also happens on the same line with `let user`, so the `user` object has not yet even been defined, hence the error.
|
||||
Then we can also see that such a joint expression is syntactically a call of the object `{ go: ... }` as a function with the argument `(user.go)`. And that also happens on the same line with `let user`, so the `user` object has not yet even been defined, hence the error.
|
||||
|
||||
If we insert the semicolon, all is fine:
|
||||
|
||||
|
@ -35,9 +35,3 @@ let user = {
|
|||
```
|
||||
|
||||
Please note that brackets around `(user.go)` do nothing here. Usually they setup the order of operations, but here the dot `.` works first anyway, so there's no effect. Only the semicolon thing matters.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue