Predict Tuple Access 输出
预测输出 简单
题目
什么做 这个 code print?
代码
const pair: [string, number] = ["age", 25];
console.log(pair[0]);
console.log(pair[1]);
console.log(pair.length);
提示
Tuples 是数组 — access 通过索引, 长度 gives 元素数量.
解释
tuple pair 有 two 元素: "age" at 索引 0 and 25 at 索引 1. pair[0] prints "age", pair[1] prints 25, and pair.长度 prints 2. tuple 类型 annotation 是 erased at 运行时.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。