12. "Eliminate" operation

This operation affects JavaScript arrays and objects.
For arrays it removes all matching array elements.
For objects it removes all matching object fields.

Let's say we have the following JavaScript array and object:
fruits = ['Mango', 'Banana', 'Annona', 'Grape', 15];

person = {
    name: 'John',
    country: 'Canada',
    age: 30
The following expression removes a 'Grape' string value from the fruits array:
The 'Grape' value followed by the - operation is treated as string as was told in introduction section.

To remove a numeric value from the array we need to provide a numeric value in the following way:
( see default value operation and type casting operation for more information )

Finally we get the following expression to remove a 30 numeric value from the array:

To remove an age property from the person object use following expression:

You can remove items from arrays and objects dynamically.
For example:
Here the myDynamicField variable can be declared in the same JavaScript file or can be provided externally as argument.

Watch a demo