import { Callout } from "nextra/components"; import REPL from "../../components/REPL";
Immutable: This does not mutate the original object. If an array value is removed, then it will not return a [sparsed](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays) array.Removes the property of the given object at the given path.
import { toUnset } from '@opentf/std';
toUnset<T>(
obj: T,
path: string | unknown[],
): T
const obj = { a: 1, b: 2 };
toUnset(obj, 'a') //=> { b: 2 }
toUnset(obj, 'b') //=> { a: 1 }
toUnset(obj, 'c') //=> { a: 1, b: 2 }
const arr = [1, 2, 3];
toUnset(arr, '0') //=> [2, 3]
toUnset(arr, '1') //=> [1, 3]
toUnset(arr, '3') //=> [1, 2, 3]
const nestedObj = { x: { y: { z: ['a', null, 'b'] } } };
toUnset(nestedObj, 'x.y.z') //=> { x: { y: {} } }
<REPL code={`const { toUnset } = require('@opentf/std');
const obj = { a: 1, b: 2 }; toUnset(obj, 'a'); `} />