We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第414天 使用delete删除数组,其长度会改变吗?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered:
不会
Sorry, something went wrong.
delete删除数组 长度不会改变
因为 delete obj.key 是通过 key 来移除对应的值
delete obj.key
key
正确且常用的方法 为arr.splice(index[,deleteCount])
arr.splice(index[,deleteCount])
长度不会改变,这里引生出另一个知识点,通过设置数组的length为0,可以清空数组。
长度不会变, 例如 var arr = [1, 2, 3] delete arr[1] -> [1, ,3],如果将数组的length设为0,则会清空数组。
var arr = [1, 2, 3] delete arr[1]
No branches or pull requests
第414天 使用delete删除数组,其长度会改变吗?
3+1官网
我也要出题
The text was updated successfully, but these errors were encountered: