Merge pull request #473 from skube/patch-3

Fix rest parameter mis-match
This commit is contained in:
Ilya Kantor 2017-03-26 23:03:45 +03:00 committed by GitHub
commit 3c6245beb8

View file

@ -53,10 +53,11 @@ Here the first two arguments go into variables and the rest goes to `titles` arr
function showName(firstName, lastName, ...titles) { function showName(firstName, lastName, ...titles) {
alert( firstName + ' ' + lastName ); // Julius Caesar alert( firstName + ' ' + lastName ); // Julius Caesar
// the rest = ["Consul", "Imperator"] // the rest go into titles array
alert( rest[0] ); // Consul // i.e. titles = ["Consul", "Imperator"]
alert( rest[1] ); // Imperator alert( titles[0] ); // Consul
alert( rest.length ); // 2 alert( titles[1] ); // Imperator
alert( titles.length ); // 2
} }
showName("Julius", "Caesar", "Consul", "Imperator"); showName("Julius", "Caesar", "Consul", "Imperator");