Skip to content

Commit

Permalink
Merge pull request ganqqwerty#85 from harmansingha/master
Browse files Browse the repository at this point in the history
Added New Method for setting default value in ES6
  • Loading branch information
ganqqwerty authored Feb 19, 2020
2 parents 8fc70b6 + a294916 commit a240ce7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,27 @@ sentEmail({
}, 'Yahoo Mail');
```
**Method 3: Setting default parameter value in ES6**
```javascript
function sendEmail(configuration, provider = "Gmail") {
// Set default value if user has not passed value for provider

// Value of provider can be accessed directly
console.log(`Provider: ${provider}`);
}

// In this call we are not passing provider parameter value
sentEmail({
from: '[email protected]',
subject: 'Test Email'
});
// Here we are passing Yahoo Mail as a provider value
sentEmail({
from: '[email protected]',
subject: 'Test Email'
}, 'Yahoo Mail');
```
## Question 48. Write code for merge two JavaScript Object dynamically.
Let say you have two objects
Expand Down

0 comments on commit a240ce7

Please sign in to comment.