当前位置:网站首页>JS learning notes 14-15: JS array and array letter quantity
JS learning notes 14-15: JS array and array letter quantity
2022-07-19 08:30:00 【The man fished alone in the cold river snow】
<!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>
<script>
var arr=new Array();
// Use typeof When checking an array , Returns the object
// console.log(typeof arr);
/* 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 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 */
arr[0]=10;
arr[1]=33;
console.log(arr.length);
// When you create an array using literals , You can specify the elements in the array at creation time
var arr=[1,2,3,4,5,10];
// When creating an array using a constructor , You can also add elements at the same time , The element to be added is passed as a parameter of the constructor
var arr2=new Array(10,20,30);
//console.log(arr2.length);
// The elements in the array can be any data type
arr=["hello",1,true,null,undefined];
// It could be an object
arr[arr.length]=obj;
var obj=[{
name:" The Monkey King "},{
name:" Pig eight quit "},{
name:" The sand monk "}];
// Add at the end of element obj // It can also be a function arr=[function(){
alert(1)},function(){
alert(2)}];
// You can also put an array in the array , The following array is called two-dimensional array
arr=[[1,2,3],[3,4,5],[5,6,7]];
console.log(arr[1]);
</script>
</head>
<body>
</body>
</html>
边栏推荐
- 49、Mysql使用
- Redis publishing and subscription
- Address monitoring API: how to trace and monitor uniswap hacker addresses
- Excellent résumé! Enfin quelqu'un a compris toutes les connexions SQL
- 演示集合注入
- 《Flutter入门》flutter计算最近1个月、3个月、半年、12个月
- STM32CUBEIDE(9)----USART通过DMA收发
- Detailed explanation of type, user-defined type, preliminary understanding of structure
- Sword finger offer 42 Maximum sum dynamic programming method for continuous subarrays
- #yyds干货盘点#Cross-origin 跨域请求
猜你喜欢

Super dry! Thoroughly understand golang memory management and garbage collection

Openfeign service interface call

46、IO模型

微服务与微服务架构

Li Kou 1669 merges two linked list notes

从 B 站崩溃报告看分布式系统的技术栈

Redis introduction

Redis新数据类型——Bitmaps

Unity: window size adaptation when running on the browser after webgl Publishing
![[kernel] character device that drives development and learning](/img/99/2eaed37078c3245be29d82382cfd59.png)
[kernel] character device that drives development and learning
随机推荐
Classic general pbootcms flower website template source code, adaptive mobile terminal, with background management
Bean、
openpyxl跨工作簿复制sheet页
Spark miscellaneous -- why reuse exchange and subquery
使用arduino开发esp8266和esp32时首选项设置方法
力扣1669合并两个链表笔记
Can seaport and erc-4907 become new ways to release NFT liquidity| Tokenview
力扣455分发饼干笔记
Eureka自我保护
Quanzhi v3s learning record (13) use of ov2640
Deep learning 7 deep feedforward network 2
SPARK中的FileSourceStrategy,DataSourceStrategy以及DataSourceV2Strategy
美国压力激增,TikTok 更换全球安全主管
TextView文字上下移动
Redis6 new data type geospatial
No module named 'yaml' solution
Redis6 new data type - hyperloglog
把HBuilderX的主题变成vscode
Redis common data types - redis list and redis set
Deep learning 7 deep feedforward network