I have an array in JavaScript and I need to find a specific element and remove it. I tried with splice()
and findIndex()
and it's not supported in JSEclipse nor in IE9. I used splice()
and find()
and it doesn't work in IE9.
There are 2 points why my question is not a duplicate:
(1) My array is an array of objects so using indexOf()
does not apply.
(2) Support in IE9 is prerequisite for my solutions.
I would appreciate any assistant.
My array:
var portingOptions = [
{
name: 'print',
iconClass: 'faxBlue'
},
{
name: 'pdf',
iconClass: 'pdfBlue'
},
{
name: 'exportToCcr',
iconClass: 'documentBlue'
},
{
name: 'message',
iconClass: 'secureMessageBlue'
},
{
name: 'email',
iconClass: 'emailBlue'
}
];
My code with splice()
and find()
:
if (myParameters.removeEmailField) {
portingOptions.splice(portingOptions.find(function(element) {
return element.name === 'email';
})
);
}
Does anyone know of a solution that will work on IE9?