当前位置:网站首页>Test next summary

Test next summary

2022-07-07 13:00:00 Social Ruidi

The first part introduces the basic concept of array and some simple array element operation functions , actually , Arrays provide many more functions .

push、pop、shift and unshift Is a function that operates on both ends of an array , As mentioned above , This article will not be repeated .

Element delete ( Object mode )
The previous article has briefly introduced , An array is a special object , So we can try to use the attribute deletion method of the object :delete.

for instance :111111

let arr = [1,2,3,4,5];
delete arr[2];
console.log(arr);
1
2
3
The code executes as follows :

Pay attention to the position marked yellow in the drawing , Although the element has been deleted , But the length of the array is still 5, And the deleted location is empty . If our access subscript is 2 The elements of , We will get the following results :
————————————————
Copyright notice : This paper is about CSDN Blogger 「@ Weidada 」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/weixin_43302112/article/details/1251053312222

原网站

版权声明
本文为[Social Ruidi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071049233647.html