Re: Destructured Objects as Parameters


Since the comments were closed, I'm noting here, that Python figured this out a while back.

Function parameters start with required positional parameters, followed by optional positional parameters, followed by named parameters.

def fun(a, b, c=10, **kwargs):

In JS this would be:

function fun(a, b, c, obj) {
    c = (c === undefined ? 10 : c);

In Typescript:

function fun(a, b, c?, obj?) {
    c = (c === undefined ? 10 : c);

Retaining positional parameters allows for function composition.