Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions proposal-unset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# ECMAScript proposal: Add method "unset" to Object.prototype

- [Motivation](#motivation)
- [High-level API](#high-level-api)
- [FAQ](#faq)

## Motivation

JavaScript Object needs method "unset" for immutable removing property from object

```js
Object.prototype.unset = function(property) {};
```

## High-level API

```js
var foo = {
a: 1,
b: 2
};

var bar = foo.unset("a");

console.log(foo); // { a: 1, b: 2 }
console.log(bar); // { b: 2 }
```

```js
var foo = {
a: 1,
b: {
c: 2,
d: 3
}
};

var bar = foo.unset("b.d");

console.log(foo); // { a: 1, b: { c: 2 } }
console.log(bar); // { b: 2, b: { c: 2, d: 3 } }
```