1

I am hoping someone can break this section of code down and help me understand just how this functions.

const buildApi = (
  disk: Disk,
  newProp: {
     sector: Sector[]
  }
): ApiDetails => { }

1 Answer 1

4

You assign the function to the buildApi variable. The function takes two parameters, disk of type Disk, newProp of type (object) {sector: Sector[]} and the function is going to return something of type ApiDetails the => is the arrow in the arrow function, while everything inside the following { } would become the body of the function.

The above is equivalent of

var buildApi = function(disk, newProp) { }

or

/*
  This is only partially true, as this one would be hoisted, the above isn't
*/
function buildApi(disk, newProp) { }

In all cases, you would invoke the function by buildApi(disk, newProp);

Sign up to request clarification or add additional context in comments.

1 Comment

Makes perfect sense now. Thanks for that clear response.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.