DEV Community

Calvin
Calvin

Posted on

2 3

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)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay