The Note: The syntax allows a wider range of expressions following the Parameters
The name of an object, or an expression evaluating to an object. property The property to delete. Return value
Exceptions
Thrown in strict mode if the property is an own non-configurable property. ReferenceError Thrown if DescriptionThe
Because
classes are automatically in strict mode, and private properties can only be legally referenced in class bodies, this means private properties can never be deleted. While While other expressions are accepted, they don't lead to meaningful behaviors:
The It is important to consider the following scenarios:
Cross-browser notesAs of modern ECMAScript specification, the traversal order of object properties is well-defined and stable across implementations. However, in the case of
Internet Explorer, when one uses If you want to use an ordered associative array with support of old runtimes, use a ExamplesUsing deleteNote: The following example uses non-strict-mode only features, like implicitly creating global variables and deleting identifiers, which are forbidden in strict mode.
delete and the prototype chainIn the following example, we delete an own property of an object while a property with the same name is available on the prototype chain:
Deleting array elementsWhen you delete an array element, the
array When the
This creates a sparse array with an empty slot. If you want an array element to exist but have an
undefined value, use the
If instead, you want to remove an array element by changing the contents of the array, use the
Deleting non-configurable propertiesWhen a property is marked as non-configurable,
In strict mode, this would raise an exception. Deleting global propertiesIf a global property is configurable (for example, via direct property assignment), it can be deleted, and subsequent references to them as global variables will produce a
Specifications
Browser compatibilityBCD tables only load in the browser See alsoHow do I delete a single file from input type file multiple?Just assign $('input:file#upload')[0]. files to an Array and then remove items from that array using splice or method of your choice and then use that Array .
How do I reset the input type file?To reset a file input in React, set the input's value to null in your handleChange function, e.g. event. target. value = null . Setting the element's value property to null resets the file input.
|