delete Removes Object Properties
delete unlinks an own property so in and hasOwn both miss it, assigning undefined keeps the key, and delete on an array leaves a hole without shrinking length.
Code
const options = { retries: 3, timeout: 1500, verbose: true };
// delete removes an own property; afterwards both in and hasOwn miss it
delete options.verbose;
console.log('verbose own:', Object.hasOwn(options, 'verbose'));
console.log('verbose in:', 'verbose' in options);
// reading a deleted property yields undefined, but that differs from "present with value undefined"
console.log('value:', options.verbose);
delete options.retries;
console.log('after delete:', JSON.stringify(options));
// assigning undefined does not remove the key: the key stays on the object
const patch = { debug: false };
patch.debug = undefined;
console.log('still own:', Object.hasOwn(patch, 'debug'));
console.log('keys:', Object.keys(patch).length);
// delete on an array leaves holes: the index property disappears while length is unchanged
const items = ['a', 'b', 'c'];
delete items[1];
console.log('index 1 present:', 1 in items);
console.log('length unchanged:', items.length);Output
Captured from a sandboxed run of this snippet in the build pipeline.
verbose own: false
verbose in: false
value: undefined
after delete: {"timeout":1500}
still own: true
keys: 1
index 1 present: false
length unchanged: 3How this snippet works
The file’s state is a handful of top-level bindings: options, patch, items.
Module-level object literal, fixed keys: retries, timeout, verbose.
Caveats
- It is dependency-free in the strict sense — the import list, if any, is empty of packages.
Using it
The file’s output announces each step as it happens: verbose own:, verbose in:, value:.
Key statements
const options = { retries: 3, timeout: 1500, verbose: true };
const patch = { debug: false };
const items = ['a', 'b', 'c'];
Interactive Tools for This Topic
Properties File ParserParse Java .properties files with comments, continuations, separators, and escapes, then emit clean JSON.Dotenv File ParserParse .env file content into a JSON object, handling comments, export prefixes, single quotes, and double-quoted escape sequences.INI File ParserParse INI configuration files into nested JSON with section objects, global keys, and both semicolon and hash comment support.JSON to TOML ConverterTurn a JSON object into TOML, emitting nested objects as tables and arrays of objects as array-of-tables blocks.
FAQ
- Does this work in a bare project with no dependencies file?
- Yes — a bare project runs it as-is, since nothing needs declaring. Every import resolves inside the standard library — `present with value undefined`. Its state lives in module-level bindings: `options`, `patch`, `items`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.