Skip to content

area for clarification - Destructuring #2

Description

@robin-raymond

https://github.com/jchadwick/EssentialTypeScriptBook/blob/master/manuscript/02.ECMAScript2015.md

function countdown({ initial, final: final = 0, interval: interval = 1, initial: current }) {

    while(current > final) {
        console.log(current);
        current -= interval;
    }

}

I totally understand that this is a low priority feature but as a long time programmer but newbie to ts, this confused me. The only thing I've seen thus far in the book is <varname> : <typename>, e.g. foo : string so in this syntax it looks like final is type final and initial is type current, but clearly that's not what's going on here. Everything else in the book has been clear but this point lost me. I would recommend tweaking this part of the book.

BTW, I'm happily enjoying the book thus far. I'll rate it on Amazon once I get further along as I'm only in the ts baby steps right now :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions