Predict 字符串 slice 输出
预测输出 中等
题目
什么做 这个 code print?
代码
const text = "JavaScript";
console.log(text.slice(0, 4));
提示
slice(开始, 端) extracts 从开始上 到 (但不 包含) 端.
解释
slice(0, 4) extracts characters from index 0 up to (but not including) index 4. "JavaScript" characters at indices 0-3 are J-a-v-a, giving "Java". The end index is exclusive.
相关资源
相关课程
- 字符串 and 文本
学习如何字符串 and 文本工作 in programming.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。