Last active
November 8, 2016 01:20
-
-
Save victorvhpg/f682e715da365c1fef014399c6b47deb to your computer and use it in GitHub Desktop.
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
//com parametro nomeado opcional | |
function teste(a, { b, c = 5}){ | |
console.log(a); | |
console.log(b); | |
console.log(c); | |
}; | |
teste(1, { b: "oi" }); //1, "oi", 5 | |
teste(99, { b: "oi", c: "aa" }); //99, "oi", aa | |
teste(1); //TypeError .... pois não passou o objeto | |
// objeto opcional | |
function teste(a, { b, c = 5} = {}){ | |
console.log(a); | |
console.log(b); | |
console.log(c); | |
}; | |
teste(2); //2,undefined,5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment