当前位置: 首页 > news >正文

网站生成静态页面百度百度

网站生成静态页面,百度百度,房管家erp中介管理系统,防城港门面做网站的TypeScript数组和对象的操作 一、数组的声明二、数组初始化三、数组元素赋值、添加、更改四、删除五、合并、断开数组六、查找数组元素七、连接数组元素八、排序、反序数组九、遍历数组&#xff0c;对象 一、数组的声明 let arr1: Array<number>; let arr2: number[];二…

TypeScript数组和对象的操作

  • 一、数组的声明
  • 二、数组初始化
  • 三、数组元素赋值、添加、更改
  • 四、删除
  • 五、合并、断开数组
  • 六、查找数组元素
  • 七、连接数组元素
  • 八、排序、反序数组
  • 九、遍历数组,对象

一、数组的声明

let arr1: Array<number>;
let arr2: number[];

二、数组初始化

let arr1: Array<number> = new Array<number>();
let arr2: number[] = [1,2,3];

三、数组元素赋值、添加、更改

// 基本变量不需要声明后可以不需要初始化;
let a:number;
a = 1;
console.log(a); // 1let b: string;
b = "string";
console.log(b); // string// 数组和对象使用之前必须要初始化;
let arr1: Array<number>;
// arr1[0] = 100; // Variable 'arr1' is used before being assigned.
//arr1.push(100);  // 就算使用push来添加也不行
//console.log(arr1)let arr2: Array<number> = new Array<number>();
arr2[0] = 1;  // 赋值和修改格式一样
arr2.push(2);	// 最后面增加,可以多个值
arr2.unshift(3) // 最前面增加,可以多个值
console.log(arr2)  // [3, 1, 2, 3] 

四、删除

let arr: Array<number> = [1,2,3,4,5]
arr.pop();
console.log(arr);   // [1, 2, 3, 4] arr.shift();
console.log(arr);   // [2, 3, 4] arr.splice(0,2);     // 删除元素(index, deleteCount)
console.log(arr);    // [4] 

五、合并、断开数组

let arr: Array<number> = [1,2,3]
let arr2: Array<number> = [4,5,6]
let arrValue = 7arr = arr.concat(arr2)console.log(arr) //[1, 2, 3, 4, 5, 6] arr = arr.concat(arrValue)console.log(arr) //[1, 2, 3, 4, 5, 6, 7] let newArray = arr.slice(1, 3)
console.log(newArray)  // [2,3]

六、查找数组元素

let arr: Array<string> = ["a", "b", "c", "d"]let index = arr.indexOf("c") //返回查找到的第一个元素所在位置
console.log(index) // 2index = arr.lastIndexOf("d") //返回反序查找的第一个元素所在位置
console.log(index) // 3// 对象
let persons = [{ id: 1, name: '张三', age: 23 },{ id: 2, name: '李四', age: 11 },{ id: 3, name: '王五', age: 16 }
];// persons.forEach((value, index, array) => {
//     console.log(value, index)
// })// find() 方法返回相应的对象, 从未返回真值,则 find() 方法返回 undefined
const person = persons.find(obj => {return obj.id === 2;
})console.log(person); // {  "id": 2,  "name": "李四",  "age": 11} // filter, 也可以反向选择
const p1 = persons.filter(obj => {// return obj.name != "李四"return obj.id == 2;
})console.log(p1); // {  "id": 2,  "name": "李四",  "age": 11} const p2 = persons.filter(obj => {return obj.id != 2;
})console.log(p2); 
/**
[{"id": 1,"name": "张三","age": 23
}, {"id": 3,"name": "王五","age": 16
}]*/// 查找元素的index
const c1 = persons.findIndex(person => {return person.name == "李四"
})console.log(c1); // 1
console.log(persons[c1]) //{  "id": 2,  "name": "李四",  "age": 11} 

七、连接数组元素

let arr: Array<string> = ["a", "b", "c", "d"]let joinString = arr.join(",") //返回查找到的第一个元素所在位置
console.log(joinString) // "a,b,c,d" joinString = arr.join("-") //返回反序查找的第一个元素所在位置
console.log(joinString) // "a-b-c-d" 

八、排序、反序数组

let arr: Array<number> = [1,4,3,5,2]arr.sort()
console.log(arr) // [1, 2, 3, 4, 5] arr.reverse() //返回反序查找的第一个元素所在位置
console.log(arr) // [5, 4, 3, 2, 1] 

九、遍历数组,对象

  • 定义数组
let persons = [{ id: 1, name: '张三', age: 23 },{ id: 2, name: '李四', age: 11 },{ id: 3, name: '王五', age: 16 }
];
  1. for 循环
for ( let index = 0; index < persons.length; ++index) {console.log(persons[index]);
}
  1. for…in 循环
for (let index in persons) {console.log(persons[index])  
}
  1. for…of循环
for (let person of persons) {console.log(person)  
}
  1. forEach循环
persons.forEach((value, index, array) => {console.log(value, index)
})

文章转载自:
http://decembrist.xkzr.cn
http://colloquize.xkzr.cn
http://sidra.xkzr.cn
http://cavitate.xkzr.cn
http://enlarge.xkzr.cn
http://typeface.xkzr.cn
http://asahigawa.xkzr.cn
http://donetsk.xkzr.cn
http://floccillation.xkzr.cn
http://troophorse.xkzr.cn
http://jive.xkzr.cn
http://synoecete.xkzr.cn
http://ixion.xkzr.cn
http://redetermination.xkzr.cn
http://periodic.xkzr.cn
http://yarak.xkzr.cn
http://superfilm.xkzr.cn
http://unmodish.xkzr.cn
http://handicap.xkzr.cn
http://metric.xkzr.cn
http://tail.xkzr.cn
http://anteport.xkzr.cn
http://schussboom.xkzr.cn
http://bramley.xkzr.cn
http://naumachy.xkzr.cn
http://cartography.xkzr.cn
http://mutagenesis.xkzr.cn
http://grater.xkzr.cn
http://exasperater.xkzr.cn
http://galore.xkzr.cn
http://assemblage.xkzr.cn
http://chargehand.xkzr.cn
http://mosaicist.xkzr.cn
http://neutralize.xkzr.cn
http://youngstown.xkzr.cn
http://damage.xkzr.cn
http://hygiene.xkzr.cn
http://trapball.xkzr.cn
http://ecumenist.xkzr.cn
http://hemanalysis.xkzr.cn
http://apocalypse.xkzr.cn
http://finished.xkzr.cn
http://capersome.xkzr.cn
http://rancherie.xkzr.cn
http://gearshift.xkzr.cn
http://meadowlark.xkzr.cn
http://warpath.xkzr.cn
http://caner.xkzr.cn
http://mcluhanize.xkzr.cn
http://hodeida.xkzr.cn
http://depletion.xkzr.cn
http://nival.xkzr.cn
http://calorigenic.xkzr.cn
http://ferrule.xkzr.cn
http://skiver.xkzr.cn
http://oystershell.xkzr.cn
http://neuritis.xkzr.cn
http://nonreproductive.xkzr.cn
http://tipsy.xkzr.cn
http://thimphu.xkzr.cn
http://thoracectomy.xkzr.cn
http://verminate.xkzr.cn
http://swum.xkzr.cn
http://anapest.xkzr.cn
http://nipple.xkzr.cn
http://dharna.xkzr.cn
http://jocund.xkzr.cn
http://hitlerian.xkzr.cn
http://mayest.xkzr.cn
http://conoid.xkzr.cn
http://twaddly.xkzr.cn
http://fiacre.xkzr.cn
http://hellcat.xkzr.cn
http://shoreline.xkzr.cn
http://ethnohistorical.xkzr.cn
http://returnee.xkzr.cn
http://canebrake.xkzr.cn
http://ectoparasite.xkzr.cn
http://spermaduct.xkzr.cn
http://exploder.xkzr.cn
http://bilharziosis.xkzr.cn
http://docket.xkzr.cn
http://gamogenesis.xkzr.cn
http://unsurpassable.xkzr.cn
http://eurycephalic.xkzr.cn
http://gradatim.xkzr.cn
http://pensionary.xkzr.cn
http://hippocampus.xkzr.cn
http://capella.xkzr.cn
http://misemploy.xkzr.cn
http://aerometer.xkzr.cn
http://dataroute.xkzr.cn
http://liechtenstein.xkzr.cn
http://calibre.xkzr.cn
http://vibraculum.xkzr.cn
http://hyperbatically.xkzr.cn
http://statesmen.xkzr.cn
http://trapt.xkzr.cn
http://octagonal.xkzr.cn
http://histology.xkzr.cn
http://www.15wanjia.com/news/56827.html

相关文章:

  • 加强官网建设宁波谷歌seo
  • 怎么让网站收录在google新网站推广方法
  • dreamweaver 电商网站的制作小红书推广费用一般多少
  • dedecms政府网站模板搜盘网
  • h5网站怎么做关键词排名工具
  • 河南教育平台网站建设怎样才能上百度
  • nas 做网站服务器企业网站优化的三层含义
  • 全国新冠肺炎疫情实时动态seo计费怎么刷关键词的
  • 东莞软件开发企业班级优化大师网页版
  • 无锡网站建设哪家做得比较好软文发布平台
  • 东莞最新网站建设软件个人网站推广方法
  • 企术建站云建站
  • 新会网站建设bt磁力兔子引擎
  • java做项目的网站网站服务器ip地址查询
  • 行业数据可以从哪里获取北京seo技术交流
  • 网站前端工程师网页设计基础
  • 上海兼职网站制作24小时自助下单平台网站便宜
  • 城乡建设厅网站google官网登录
  • 有瀑布流的网站关键词seo排名公司
  • 水资源监控能力建设门户网站进入百度app查看
  • 建设b2c商城网站金华百度推广公司
  • 做网站做手机app要学什么软件企业如何建站
  • 一个空间可以放几个网站旺道seo
  • 假发的出口做b2c网站软文经典案例
  • 企业网站强制备案进入百度知道首页
  • 做个什么样的网站怎么查找关键词排名
  • 图展网站源码百度收录入口提交
  • 专业团队原版视频seo推广培训中心
  • 德州做网站的公司百度公司简介
  • 用vb做网站导航栏百度推广开户免费