当前位置:网站首页>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');
边栏推荐
猜你喜欢
wx小程序学习笔记day01
Easy to use PDF to SVG program
朗坤智慧冲刺科创板:年营收4亿 拟募资7亿
[.Net core] solution to error reporting due to too long request length
Hongke shares | plate by plate ar application in Beijing Winter Olympics
None of the strongest kings in the monitoring industry!
手写一个的在线聊天系统(原理篇1)
图之广度优先遍历
Shangsilicon Valley JUC high concurrency programming learning notes (3) multi thread lock
287. Find duplicates
随机推荐
巨杉数据库首批入选金融信创解决方案!
视频化全链路智能上云?一文详解什么是阿里云视频云「智能媒体生产」
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
CSRF漏洞分析
Test 1234
Implementation of AVL tree
Jdbc driver, c3p0, druid and jdbctemplate dependent jar packages
Optical blood pressure estimation based on PPG and FFT neural network [translation]
With the implementation of MapReduce job de emphasis, a variety of output folders
On AAE
44所高校入选!分布式智能计算项目名单公示
美庐生物IPO被终止:年营收3.85亿 陈林为实控人
ORACLE进阶(四)表连接讲解
Introduction and case analysis of Prophet model
首先看K一个难看的数字
小程序在产业互联网中的作用
node の SQLite
Jushan database was among the first batch of financial information innovation solutions!
AFNetworking框架_上传文件或图像server
Mathematics in machine learning -- common probability distribution (XIII): Logistic Distribution