open-ended function arguments with TypeScript

后端 未结 3 979
灰色年华
灰色年华 2020-11-28 05:23

IMO, one of the main concerns of the TypeScript language is to support the existing vanilla JavaScript code. This is the impression I had at first glance. Take a look at the

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 06:26

    In addition to @chuckj answer: You can also use an arrow function expression in TypeScript (is kind of a lambda in Java / .NET)

    function sum(...nums: number[]): number {
        return nums.reduce((a, b) => a + b, 0);
    }
    

提交回复
热议问题