同问
开发者问题收集
为什么使用 length 方法时会出现“TypeError: 无法读取未定义的属性‘length’”
我编写了一个返回最长单词的函数const longestWord = (phrase) => {const arr = phrase.split(" ");let longest;for (let i = 0; i < arr.length; i++) {if (arr[i].length < arr[i+1].length){longest = arr[i+1][arr[i]] = [arr[i
javascript
arrays
for-loop
typeerror
variable-length
2022-09-11
«
1
»