Commit abb064d
authored
Update 03_default_function_arguments.md
Added below content
Note: We now don't need to construct object and equate to an empty object. Alternative to above we can construct a function as below
``` javascript
function calculatePrice({
total = 0,
tax = 0.1,
tip = 0.05}){
return total + (total * tax) + (total * tip);
}```
and the below code would work normal
```js
calculatePrice({});
// 0
calculatePrice();
// 0
calculatePrice(undefined)
// 0
```1 parent 07de969 commit abb064d
1 file changed
+25
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
91 | 95 | | |
92 | 96 | | |
93 | 97 | | |
| |||
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
0 commit comments