1

I have this array of objects:

var data = [{
    "code": "8252",
    "name": "Věšák Sentini, antik mosaz",
  },
  {
    "code": "8253",
    "name": "Věšák Sentini, matný chrom",
  },
  {
    "code": "8254",
    "name": "Věšák Sentini, antik měď",
  },
  {
    "code": "8261",
    "name": "Věšák Kasper I, matný nikl",
  }
]

How can I remove the object from array that has code == 8254 please?

1 Answer 1

1

You can use array.filter to get a new array without specified element:

var data = [{
    "code": "8252",
    "name": "Věšák Sentini, antik mosaz",
  },
  {
    "code": "8253",
    "name": "Věšák Sentini, matný chrom",
  },
  {
    "code": "8254",
    "name": "Věšák Sentini, antik měď",
  },
  {
    "code": "8261",
    "name": "Věšák Kasper I, matný nikl",
  }
]

let output = data.filter(x => x.code !== "8254");

console.log(output);

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.