Last active
December 29, 2015 20:19
-
-
Save nola/7722909 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //The delete operator deletes an object, an object's property, or an element at a specified index in an array. Syntax: | |
| delete objectName; | |
| delete objectName.property; | |
| delete objectName[index]; | |
| delete property; // legal only within a with statement | |
| //If the delete operator succeeds, it sets the property or element to undefined. | |
| //The delete operator returns true if the operation is possible; it returns false if the operation is not possible. | |
| x = 42; | |
| var y = 43; | |
| myobj = new Number(); | |
| myobj.h = 4; // create property h | |
| delete x; // returns true (can delete if declared implicitly) | |
| delete y; // returns false (cannot delete if declared with var) | |
| delete Math.PI; // returns false (cannot delete predefined properties) | |
| delete myobj.h; // returns true (can delete user-defined properties) | |
| delete myobj; // returns true (can delete if declared implicitly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment