for-in statement

后端 未结 4 1198
花落未央
花落未央 2020-11-30 07:07

TypeScript docs say nothing about loop like for or for-in. From playing with the language it seems that only any or string

4条回答
  •  無奈伤痛
    2020-11-30 07:40

    In Typescript 1.5 and later, you can use for..of as opposed to for..in

    var numbers = [1, 2, 3];
    
    for (var number of numbers) {
        console.log(number);
    }
    

提交回复
热议问题