const a = () = > ({ a = 1, b = 2} = {}) :number= > 11;
Copy the code

JavaScript functions generated after compilation:

var a = function () { return function (_a) {
    var _b = _a === void 0 ? {} : _a, _c = _b.a, a = _c === void 0 ? 1 : _c, _d = _b.b, b = _d === void 0 ? 2 : _d;
    return 11;
}; };
Copy the code

Jerry added some comments like this:

// a is a function that, after being called, returns a new function that takes an input parameter _a:

var a = function () { 
	return function (_a) {
	// define a temporary variable _b to store the value of the input parameter _a. If the input parameter _a is undefined, then the value of _B is the default, an empty object
	Otherwise, _b is equivalent to _A
    var _b = _a === void 0 ? {} : _a;

    // _c stores the value of field A in the input parameter
    var _c = _b.a;

    // If field A of the input parameter is empty, the default value 1 is assigned, otherwise the value of field A of the input parameter passed in is used
    var a = _c === void 0 ? 1 : _c;

    // _d stores the value of the b field of the input parameter
    var _d = _b.b;

    // If the b field is empty, use the default value 2, otherwise use the value passed in
    var b = _d === void 0 ? 2 : _d;
    return 11;
}; };
Copy the code