File tree
Expand file treeCollapse file tree1 file changed
+6
-6
lines changed Expand file treeCollapse file tree1 file changed
+6
-6
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -562,22 +562,22 @@ be very expensive in terms of performance.
|
562 | 562 |
|
563 | 563 | **Bad:**
|
564 | 564 | ```javascript
|
565 |
| -const addItemToCart = function (cart, item) { |
566 |
| -cart.push({ item: item, date: Date.now() }); |
| 565 | +const addItemToCart = (cart, item) => { |
| 566 | +cart.push({ item, date: Date.now() }); |
567 | 567 |
|
568 | 568 | return cart;
|
569 |
| -} |
| 569 | +}; |
570 | 570 | ```
|
571 | 571 |
|
572 | 572 | **Good:**
|
573 | 573 | ```javascript
|
574 |
| -const addItemToCart = function (cart, item) { |
| 574 | +const addItemToCart = (cart, item) => { |
575 | 575 | const c = Object.assign({}, cart);
|
576 | 576 |
|
577 |
| -c.push({ item: item, date: Date.now() }); |
| 577 | +c.push({ item, date: Date.now() }); |
578 | 578 |
|
579 | 579 | return c;
|
580 |
| -} |
| 580 | +}; |
581 | 581 | ```
|
582 | 582 |
|
583 | 583 | **[⬆ back to top](#table-of-contents)**
|
|
You can’t perform that action at this time.
0 commit comments