I am quite new to Typescript so apologises if it is a simple answer.
I'm looking to remove the end item from an array.
const arr = [];
array consist of 3 classes:
{class1,class2,class3}
if .push is to input, what is to remove?
Thank you.
CodePudding user response:
Answer found here (Link) by Darren z:
arr.splice(-1)
CodePudding user response:
GitHub Copilot will give you the answer :)
class class1 {}
class class2 {}
class class3 {}
const arr = [class1, class2, class3];
// remove the second item from arr
arr.splice(1, 1);
// remove class3 from arr by value
arr.splice(arr.indexOf(class3), 1);