为什么这段代码没有显示我想要的结果? [已关闭]

问题描述 投票:0回答:1

let numArr2 = [1, 2, 3, 4, 5, 6, 7];
numArr2.splice(1, 1);
console.log(`Length of the numArr2 is ${numArr2.length()}`);

为什么这段代码没有显示

numArr2
的长度?

javascript
1个回答
0
投票

长度是一个正确的值,而不是一个方法,请删除括号。

let numArr2 = [1, 2, 3, 4, 5, 6, 7];
numArr2.splice(1, 1);
console.log(`Length of the numArr2 is ${numArr2.length}`);
© www.soinside.com 2019 - 2024. All rights reserved.