当前位置:网站首页>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');
边栏推荐
- Docker installation redis
- Execution process of MySQL query request - underlying principle
- Use cpolar to build a business website (1)
- 裕太微冲刺科创板:拟募资13亿 华为与小米基金是股东
- Grafana 9.0 is officially released! It's the strongest!
- Unity资源顺序加载的一个方法
- openmv4 学习笔记1----一键下载、图像处理背景知识、LAB亮度-对比度
- 首先看K一个难看的数字
- POJ 2208 已知边四面体六个长度,计算体积
- Jushan database was among the first batch of financial information innovation solutions!
猜你喜欢

Mathematics in machine learning -- common probability distribution (XIII): Logistic Distribution

Handwritten online chat system (principle part 1)

Online notes

Some understandings of tree LSTM and DGL code implementation

Penetration test information collection - CDN bypass

小程序在产业互联网中的作用

Human bone point detection: top-down (part of the theory)

2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目

Implementation of AVL tree

Excellent open source fonts for programmers
随机推荐
被疫情占据的上半年,你还好么?| 2022年中总结
ORACLE进阶(四)表连接讲解
First, look at K, an ugly number
About NPM install error 1
2022-2024年CIFAR Azrieli全球学者名单公布,18位青年学者加入6个研究项目
AFNetworking框架_上传文件或图像server
Execution process of MySQL query request - underlying principle
Epoll () whether it involves wait queue analysis
Test 1234
Summary of performance knowledge points
Picture zoom Center
STM32+MFRC522完成IC卡号读取、密码修改、数据读写
Installation and management procedures
Interpreting cloud native technology
None of the strongest kings in the monitoring industry!
上海部分招工市场对新冠阳性康复者拒绝招录
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
DOM简要
A method of sequentially loading Unity Resources
Example of implementing web server with stm32+enc28j60+uip protocol stack