JS-对象-array数组


html 复制代码
<!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>JS-对象-Array</title>
</head>
<body>
    
</body>
<script>
    //定义数组
   //var arr=new Array(1,2,3);
   //var arr=[1,2,3]

   //console.log(arr[0]);
   //console.log(arr[1]);

   //特点;长度可变 类型可变
   var arr=[1,2,3];
    arr[10]=99;

   /*console.log(arr[10]);
   console.log(arr[4]);

   arr[4]="so";
   arr[5]=true;
   console.log(arr[4]);
   console.log(arr[5]); */

   
  /*  for (let i = 0; i < arr.length; i++) {
    console.log(arr[i]);
    
    
   }  */

   //console.log("===========");
   //forEach 遍历数组中有值的元素
  /*  arr.forEach(function(e){
    console.log(e);
    
    
   }) */

   //箭头函数 (..)=>{}  用于简化函数定义

   /* arr.forEach((e)=>{
    console.log(e);
    
    
   }) */
   
   //push添加元素到末尾
   //arr.push(4,5,6);
   //console.log(arr);

   //splice 删除数组元素
   arr.splice(0,1);
   console.log(arr);
   
   

</script>
</html>
相关推荐
KaMeidebaby14 小时前
卡梅德生物技术快报|PD1 单克隆抗体定制配套 N 糖全谱质控开发
前端·人工智能·算法·数据挖掘·数据分析
nuIl15 小时前
实现一个 Coding Agent(3):工具调用
前端·agent·cursor
nuIl15 小时前
实现一个 Coding Agent(4):ReAct 循环
前端·agent·cursor
AAA大运重卡何师傅(专跑国道)15 小时前
【无标题】
开发语言·c#
nuIl15 小时前
实现一个 Coding Agent(1):一次 LLM 调用
前端·agent·cursor
nuIl15 小时前
实现一个 Coding Agent(2):让 LLM 流式响应
前端·agent·cursor
copyer_xyf15 小时前
Python 异常处理
前端·后端·python
sugar__salt15 小时前
从栈队列数据结构到JS原型面向对象全解
前端·javascript·数据结构
XBodhi.15 小时前
Visual Studio C++ 语法错误: 缺少“;”(在“return”的前面)
开发语言·c++·visual studio
MageGojo15 小时前
随机文案模块怎么做?从接口封装到前端展示的完整实现思路
javascript·前端开发·api接口·后端开发·随机文案