Reply to comment

Re: Destructured Objects as Parameters

Re: https://css-tricks.com/new-favorite-es6-toy-destructured-objects-parameters/#more-244951

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.

Reply

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

7 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.