DEV Community

Calvin
Calvin

Posted on

Reading Snippets [46 => Objects] ๐Ÿ“”

The only way to remove a property from an object is to use the delete operator. Using null or 0 only removes the value associated with the property but not the key.

The keyword may need to be notated as a string literal in order for it to be properly interpreted by older JavaScript engines.


var test = {
    'case': 'I am a keyword, so I must be notated as a string',
    delete: 'I am a keyword, so me too' // raises SyntaxError
};

Enter fullscreen mode Exit fullscreen mode

Source:JavaScript Garden

Top comments (0)