当前位置:网站首页>2022.2.12
2022.2.12
2022-07-06 18:46:00 【z318969887】
Insert delete array elements
// It can only be inserted and deleted from the tail arr.push(0);//push, write in , That is, insert the element in parentheses in the last position of the array , Numbers without quotation marks , Characters with quotation marks arr.pop();//pop, Delete , Delete the last element in the array , There is no need to fill in the brackets ,pop You can only delete one by one
// It can only be inserted and deleted from the head arr.shift(1);// Insert... From the head , Be similar to push arr.unshift();// Remove... From the head , Be similar to pop
Sort
arr.sort();//sort The function is to sort , There is no need to enter a value in brackets
Element inversion
arr.reverse();// Arrange all the elements in the array in the reverse order of the current order
Link string
arr.concat(arr1);// In brackets , If it is an array variable, fill in the variable name directly , If it's a hashed element , Then add brackets ; notes :concat The array is not modified , Only a new array is returned
Connector
arr.join('-');// Fill in the brackets with what you want to connect , Just a style , Output is as follows : arr.join('-') '0-7-5-2-3-1-6-4-9'// notes : Quotation marks must be added in brackets
Multidimensional arrays
arr = [[x,x,···],[x,x,···],[x,x,···]];// Multidimensional array is the nesting of arrays console.log(arr[1][1]);// Use the subscript of multidimensional array to get
5、 object
Several key value pairs
'use strict'; let person = { name:"zhangsan", age:3, email:"[email protected]", score:0 }// Define an object , Its content “name”、“age” Etc. are the properties of the object , The type of attribute is string type
Object Assignment
person.name = "lisi";// Assignment of elements in the object person.age;// Output the value of the corresponding attribute of the object
If you use a nonexistent object, there will be no error , Will be output “undefined”
Delete properties dynamically
delete person.name;// Whether it exists or not, it will return a true, When the deleted attribute is output again undefined
Add properties dynamically
person.sex = "man";// Directly add violence
Determine whether the property value is in the object
'score' in person;// The format is xxx attribute in xxx object true 'toString' in person;// inheritance , The properties of the parent class can also be found in this object true
Determine whether a property is owned by the object itself
person.hasOwnProperty('age');
边栏推荐
- Alibaba cloud international ECS cannot log in to the pagoda panel console
- Maixll dock camera usage
- Nuc11 cheetah Canyon setting U disk startup
- Jushan database was among the first batch of financial information innovation solutions!
- Summary of performance knowledge points
- 44所高校入选!分布式智能计算项目名单公示
- wx小程序学习笔记day01
- From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
- 二叉搜索树
- Markdown syntax for document editing (typera)
猜你喜欢
Online notes
From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
Penetration test information collection - WAF identification
AvL树的实现
小程序在产业互联网中的作用
Medical image segmentation
About NPM install error 1
抽象类与抽象方法
[.Net core] solution to error reporting due to too long request length
深度循环网络长期血压预测【翻译】
随机推荐
抽象类与抽象方法
十、进程管理
Medical image segmentation
STM32+MFRC522完成IC卡号读取、密码修改、数据读写
Penetration test information collection - CDN bypass
With the implementation of MapReduce job de emphasis, a variety of output folders
视频化全链路智能上云?一文详解什么是阿里云视频云「智能媒体生产」
Example of implementing web server with stm32+enc28j60+uip protocol stack
Deep circulation network long-term blood pressure prediction [translation]
Visual Studio Code启动时提示“Code安装似乎损坏。请重新安装。”、标题栏显示“不受支持”信息的解决办法
[.Net core] solution to error reporting due to too long request length
DOM简要
Bonecp uses data sources
Reproduce ThinkPHP 2 X Arbitrary Code Execution Vulnerability
爬虫玩得好,牢饭吃到饱?这3条底线千万不能碰!
Some recruitment markets in Shanghai refuse to recruit patients with covid-19 positive
DOM Brief
使用cpolar建立一个商业网站(1)
被疫情占据的上半年,你还好么?| 2022年中总结
C#/VB.NET 给PDF文档添加文本/图像水印