TypeScript

TypeScript

TypeScript

遍历数组

1
2
3
4
5
6
let someArray = [1, "string", false];

for (let entry of someArray) {
    console.log(entry); // 1, "string", false

}

for of怎么获取index

1
2
3
4
5
let someArray = [1, "string", false];

for (let index, entry of someArray.entries()) {
    console.log(index, entry); // 1, "string", false
}

数组增加减少元素

array1.push(xxx)