[Solved] javascript filter and slice does not work properly


here the array with processsteptemplate = 10 is removed

let arr = [
{id: 14, conditiontype: 1, processsteptemplate: 9, deleted: false, processTemplate_id: 0},
{id: 15, conditiontype: 1, processsteptemplate: 9, deleted: false, processTemplate_id: 0},
{id: 16, conditiontype: 1, processsteptemplate: 10, deleted: false, processTemplate_id: 0}
]

let step = 9;

let result = arr.filter((e) => e.processsteptemplate === step);

console.log(result);

What you were probably doing wrong was that you were assuming

arr.filter((e) => e.processsteptemplate === step);

would change the value in the current array, that is not true, it would return a new array which is now stored in result as you can now see in the above code snippet

1

solved javascript filter and slice does not work properly