Update README.md

master
Matt Huntington 8 years ago committed by GitHub
parent 9515e1b645
commit b41277dfee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -648,19 +648,6 @@ console.log(a); // 3
console.log(b); // 5
```
Use this for default options arguments:
```JavaScript
function drawES2015Chart({size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}) {
console.log(size, cords, radius);
}
drawES2015Chart({
cords: {x: 18, y: 30},
radius: 30
});
```
You can pull values from a function argument that's an object:
```JavaScript
@ -680,6 +667,19 @@ function userId({id}) {
console.log('userId: ' + userId(user)); // "userId: 42"
```
Use this for default options arguments:
```JavaScript
function drawES2015Chart({size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}) {
console.log(size, cords, radius);
}
drawES2015Chart({
cords: {x: 18, y: 30},
radius: 30
});
```
If you have a property name which is not a valid variable name, you can reassign it:
```JavaScript

Loading…
Cancel
Save