Splat operators in JavaScript, equivalent to *args and **kwargs in Python?

ES6 added a spread operator to JavaScript.

function choose(choice, ...availableChoices) {
    return availableChoices[choice];
}

choose(2, "one", "two", "three", "four");
// returns "three"

Leave a Comment