-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ganqqwerty#85 from harmansingha/master
Added New Method for setting default value in ES6
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|