coding style conflict with the tutorial itself
variable user is using for both string and object type different values. these situation is called "ninja code" bu author :) "Add a new variable only when absolutely necessary. Instead, reuse existing names. Just write new values into them." https://javascript.info/ninja-code
This commit is contained in:
parent
d5195b5d59
commit
b32ce2c9a0
1 changed files with 2 additions and 2 deletions
|
@ -425,9 +425,9 @@ alert( numbers[1] ); // 1
|
|||
Or for nested objects:
|
||||
|
||||
```js run
|
||||
let user = '{ "name": "John", "age": 35, "isAdmin": false, "friends": [0,1,2,3] }';
|
||||
let userData = '{ "name": "John", "age": 35, "isAdmin": false, "friends": [0,1,2,3] }';
|
||||
|
||||
user = JSON.parse(user);
|
||||
let user = JSON.parse(userData);
|
||||
|
||||
alert( user.friends[1] ); // 1
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue