当前位置:网站首页>Arrays in JS
Arrays in JS
2022-06-23 15:11:00 【Liujiayi_】
Catalog
(1) Read the elements in the array
(2) Gets the length of the array
Array (Array)
- An array is also an object
- It functions like our normal objects , It's also used to store some values - The difference is that ordinary objects use strings as property names ,
Arrays use numbers as index elements
- Indexes :
from 0 The starting integer is the index
- The storage performance of arrays is better than that of ordinary objects , In development, we often use arrays to store some data
(1) Read the elements in the array
grammar : Array [ Indexes ]
If you read a nonexistent index , Instead of reporting an error, he returns undefined
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
var sz = new Array();
sz[0] = 1;
sz[1] = 2;
sz[2] = 3;
alert(sz[1]);
</script>
</body>
</html>

(2) Gets the length of the array
have access to length Property to get the length of the array ( Number of elements ) grammar . Array .length
For continuous arrays , Use length You can get the length of the array ( Number of elements )
For discontinuous arrays , Use length Will get the largest index of the array +1
Try not to create discontinuous arrays
(3) modify length
If modified length Larger than the original length , Then the extra part will be empty
If modified length Less than the original length , The extra elements will be deleted
边栏推荐
- 打印内存站信息
- How to solve the problem that iterative semi supervised training is difficult to implement in ASR training? RTC dev Meetup
- ACM Player Illustration leetcode remove element
- PHP指定字段大于100正序排,小于100随机排
- 快速排序的简单理解
- 从3开始,在业务系统中增加分页功能
- 2021-05-22
- 加快 yarn install 的三个简单技巧
- An idea plug-in for automatically generating unit tests
- 2021-05-08
猜你喜欢
随机推荐
2021-04-15
What do you mean by waiting for insurance records? Where should I go for filing?
JS里的数组
这届文娱人,将副业做成了主业
信贷产品额度定价场景下的回归模型效果评估
idea查看.class文件 idea查看.class文件夹
32. Compose 优美的触摸动画
2021-06-07
Qu'est - ce que ça veut dire? Où dois - je m'inscrire?
力扣解法汇总513-找树左下角的值
2021-04-15
AXI_Round_Robin_Arbiter 设计 - AW、W通道部分
【二级等保】过二级等保用哪个堡垒机品牌好?
Volatile~ variables are not visible under multithreading
HCIA network foundation
js中的push函数介绍
WebService interface publishing and calling
An idea plug-in for automatically generating unit tests
Self inspection is recommended! The transaction caused by MySQL driver bug is not rolled back. Maybe you are facing this risk!
5分钟快速上线Web应用和API(Vercel)







