当前位置:网站首页>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 popSort
arr.sort();//sort The function is to sort , There is no need to enter a value in bracketsElement inversion
arr.reverse();// Arrange all the elements in the array in the reverse order of the current orderLink 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 returnedConnector
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 bracketsMultidimensional 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 typeObject Assignment
person.name = "lisi";// Assignment of elements in the object person.age;// Output the value of the corresponding attribute of the objectIf 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 undefinedAdd properties dynamically
person.sex = "man";// Directly add violenceDetermine 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 trueDetermine whether a property is owned by the object itself
person.hasOwnProperty('age');
边栏推荐
- 上海部分招工市場對新冠陽性康複者拒絕招錄
- Huawei 0 foundation - image sorting
- 朗坤智慧冲刺科创板:年营收4亿 拟募资7亿
- [sword finger offer] 60 Points of N dice
- STM32+HC05串口蓝牙设计简易的蓝牙音箱
- A method of sequentially loading Unity Resources
- 2022/02/12
- Automatic reservation of air tickets in C language
- Visual Studio Code启动时提示“Code安装似乎损坏。请重新安装。”、标题栏显示“不受支持”信息的解决办法
- AcWing 3537.树查找 完全二叉树
猜你喜欢

抽象类与抽象方法

How are you in the first half of the year occupied by the epidemic| Mid 2022 summary

Online notes

Method of accessing mobile phone storage location permission under non root condition

根据PPG估算血压利用频谱谱-时间深度神经网络【翻】

ORACLE进阶(四)表连接讲解

徐翔妻子应莹回应“股评”:自己写的!

Nuc11 cheetah Canyon setting U disk startup

【中山大学】考研初试复试资料分享

Easy to use PDF to SVG program
随机推荐
Deep circulation network long-term blood pressure prediction [translation]
node の SQLite
DOM Brief
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
Implementation of AVL tree
爬虫玩得好,牢饭吃到饱?这3条底线千万不能碰!
Hongke shares | plate by plate ar application in Beijing Winter Olympics
同宇新材冲刺深交所:年营收9.47亿 张驰与苏世国为实控人
Reproduce ThinkPHP 2 X Arbitrary Code Execution Vulnerability
From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
根据PPG估算血压利用频谱谱-时间深度神经网络【翻】
Summary of performance knowledge points
Penetration test information collection - WAF identification
Huawei 0 foundation - image sorting
Nuc11 cheetah Canyon setting U disk startup
openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
【中山大学】考研初试复试资料分享
Crawling data encounters single point login problem
被疫情占据的上半年,你还好么?| 2022年中总结
文档编辑之markdown语法(typora)