• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Miscellaneous / Remove an item from an object

Remove an item from an object

Remove an item from an object

Use the delete operator on the key to remove.

var lunch = {
	sandwich: 'turkey',
	chips: 'cape cod',
	drink: 'soda'
};

// Remove the chips key from the lunch object
delete lunch.chips;

// logs {sandwich: 'turkey', drink: 'soda'}
console.log(lunch);

Source

https://vanillajstoolkit.com/reference/objects/delete/

Miscellaneous

Related Snippets:

  • Determine whether two values are the same value
  • How To Add A Table Row In JavaScript
  • How To Sort An Array of Objects by String Property Value in JavaScript
  • Two ways to remove a specific item in an array

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers