Skip to content

Commit d00ca4c

Browse files
committed
Fix Object.assign example
1 parent bd8bd1e commit d00ca4c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -476,19 +476,22 @@ createMenu(menuConfig);
476476
**Good**:
477477
```javascript
478478
var menuConfig = {
479-
title: null,
480-
body: 'Bar',
481-
buttonText: null,
479+
title: 'Order',
480+
// User did not include 'body' key
481+
buttonText: 'Send',
482482
cancellable: true
483483
}
484484

485485
function createMenu(config) {
486-
Object.assign(config, {
486+
config = Object.assign({}, {
487487
title: 'Foo',
488488
body: 'Bar',
489489
buttonText: 'Baz',
490490
cancellable: true
491-
});
491+
}, config);
492+
493+
// config now equals: {title: "Order", body: "Bar", buttonText: "Send", cancellable: true}
494+
// ...
492495
}
493496

494497
createMenu(menuConfig);
@@ -1204,7 +1207,7 @@ class Square extends Shape {
12041207
setLength(length) {
12051208
this.length = length;
12061209
}
1207-
1210+
12081211
getArea() {
12091212
return this.length * this.length;
12101213
}

0 commit comments

Comments
 (0)