An array of

find()

[1.2.5.9].find( n= > { n > 4 }) 
/ / 5
Copy the code

Returns the first true value in the array, or undefined if no value is found.

findIndex()

[1.2.5.9].findIndex( n= > { n > 4 }) 
/ / 2
Copy the code

Returns the position of the first member in the array that matches the condition (return true), or -1 if no value is found.

includes(n, t)

[1.2.5.9].includes(5) // true
Copy the code

Returns a Boolean type, true if the element is found, false if it is not. N indicates the element to look for, and t indicates where to start (the default is 0).

Extended operators (somewhat like the inverse of the remaining arguments)

console.log(... [4.5.6])
/ / 4 5 6

console.log(5. [6.7].8)
// 5 6 7 8
Copy the code

join()

const arr = ['ian'.'joan'.'alex']
const text = arr.join(The '#')
console.log(text)
// "ian#joan#alex"
Copy the code

The parameter added in the join method is the delimiter. If the parameter is empty, the default partition is’, ‘.

concat()

const arr1 = [1.2.3]
const arr2 = [4.5.6]
const arr3 = arr1.concat(arr2)
console.log(arr3)
/ / [6]
Copy the code

Returns a new array that combines two ARr1 and arR2.

Pop, push, unshift, shift, sort, splice, slice, etc

Developer.mozilla.org/zh-CN/docs/…

object

Object.keys()

let obj = {
  name: 'Ming'.age: 23.action: {
    123: '123'.456: '456'}}console.log(Object.keys(obj)); 
// ["name","age","action"]
Copy the code

Returns an array containing the key names of all the enumerable properties of the object itself.

Object.values()

const obj = { name: 'Ian'.age: 23 };
Object.values(obj)
// ["Ian", 23]
Copy the code

Returns an array containing the key values of all the enumerable properties of the object itself.

Object.entries()

const obj = { name: 'Ian'.age: 23 };
Object.entries(obj)
// [ ["name", "Ian"], ["age", 23] ]
Copy the code

Returns an array containing key-value pairs of all the enumerable properties of the object itself.

Object.fromEntries()

Object.fromEntries([
  ['name'.'Ian'],
  ['age'.23]])// { name: "Ian", age: 23 }
Copy the code

Returns an Object. The Object.fromentries () method is the inverse of Object.entries() and is used to turn an array of key-value pairs into objects.

Object.assign() (shallow copy)

const obj = { name: 'Ian'.age: 23 };
const obj1 = Object.assign({},obj);
console.log(obj1)
// { name: 'Ian', age: 23 }
Copy the code