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

await axios get

await axios get

Lấy tháng hiện tại trong javascript

Lấy tháng hiện tại trong javascript

try/catch es10

An update for developer convience allows the use of try/catch without an explicit e Error reference in the catch call.

Getting the last element of a split string array

Getting the last element of a split string array

Rest Operator for Objects

Now we can use rest on the properties of an Object. It allows us to explicitly extract certain named variables, and assign any uncalled variables into a catchall Object.