@babel/plugin-transform-parameters

    This plugin transforms ES2015 parameters to ES5, this includes:

    • Destructuring parameters
    • Default parameters
    • Rest parameters

    In

    1. function test() {
    2. var x =
    3. var _ref = arguments[1];
    4. var a = _ref.a,
    5. b = _ref.b;
    6. for (
    7. var _len = arguments.length,
    8. args = Array(_len > 2 ? _len - 2 : 0),
    9. _key = 2;
    10. _key++
    11. ) {
    12. args[_key - 2] = arguments[_key];
    13. }
    14. }

    Default parameters desugar into let declarations to retain proper semantics. If this is not supported in your environment then you’ll need the @babel/plugin-transform-block-scoping plugin.

    1. {
    2. "plugins": ["@babel/plugin-transform-parameters"]
    3. }
    1. require("@babel/core").transformSync("code", {
    2. });

    boolean, defaults to false.

    Under the ignoreFunctionLength assumption, Babel will generate a more performant solution as JavaScript engines will fully optimize a function that doesn’t reference arguments. Please do your own benchmarking and determine if this option is the right fit for your application.

    1. // Spec behavior
    2. function bar1(arg1 = 1) {}
    3. bar1.length; // 0
    4. // ignoreFunctionLength: true
    5. function bar1(arg1 = 1) {}