Remove item in array javascript es6

array,tipjs

Những bạn nào mà đã sử dụng ES6 một thời gian rồi thì có thể sử dụng method array.filter() 

# remove a item in array

const items = [1, 2, 3, 4, 5]
const valueToRemove = 4
const filteredItems = items.filter(item => item !== valueToRemove)
/*
  Output:
  [1, 2, 3, 5]
*/

# sử dụng array.filter() để remove multiple item in array javascript

const items = [1, 2, 3, 4, 5]
const valuesToRemove = [3, 4]
const filteredItems = items.filter(item => !valuesToRemove.includes(item))
console.log(filteredItems)
/*
  Output:
  [1, 2, 5]
*/

Có thể bạn đã miss một số snippets code

Converting Object to an Array

Converting Object to an Array

Kiểm tra phần tử trùng trong mảng JavaScript

Kiểm tra phần tử trùng trong mảng JavaScript.

Spread Operator for Objects

Using the spread operator during an Object declaration will assign the properties of the referenced Object to the new Object.

Rolling loading

Nguyên tắc là theo dõi các sự kiện cuộn trang và phân tích mối quan hệ thuộc tính giữa clientHeight , scrollTop và scrollHeight .

Random Number javascript

Random Number javascript