fixes
This commit is contained in:
parent
25e97bb50e
commit
468a769b51
3 changed files with 5 additions and 6 deletions
|
@ -1,11 +1,10 @@
|
|||
Just loop over the object and `return false` immediately if there's at least one property.
|
||||
|
||||
```js
|
||||
function isEmpty(obj)
|
||||
function isEmpty(obj) {
|
||||
for(let key in obj) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -233,12 +233,11 @@ In real code we often use existing variables as values for property names.
|
|||
For instance:
|
||||
|
||||
```js run
|
||||
function makeUser() {
|
||||
let name = prompt("Name?");
|
||||
let age = prompt("Age?");
|
||||
function makeUser(name, age) {
|
||||
return {
|
||||
name: name,
|
||||
age: age
|
||||
// ...other properties
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -256,6 +255,7 @@ function makeUser(name, age) {
|
|||
return {
|
||||
name, // same as name: name
|
||||
age // same as age: age
|
||||
// ...
|
||||
};
|
||||
*/!*
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue