Last active
April 13, 2016 20:19
-
-
Save DanielMSchmidt/e7896de8933f542f0fb5e91a1a6aa22a to your computer and use it in GitHub Desktop.
optional function parameters
This file contains hidden or 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
function foo(a,b,c,d,e) { | |
//... | |
} | |
// place a | |
foo(1,2,3,undefined,5); | |
// place b | |
foo(1,2,3,4); | |
// place c | |
foo(42); |
This file contains hidden or 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
// Voila, the default values are all inclusive | |
function foo({a=1, b={}, c=[], d=42, e=3}) { | |
//... | |
} | |
// place a | |
foo({a: 1, b: 2, c: 3, d: 5}); | |
// place b | |
foo({a:1, b: 2, c: 3, d: 4}); | |
// place c | |
foo({a: 42}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment