UNPKG

394 BJavaScriptView Raw
1/**
2 * Clones an object but misses a key.
3 */
4
5module.exports = function cloneWithout (object, key) {
6 if (Array.isArray(object)) {
7 return object.slice(0, +key).concat(object.slice(+key + 1))
8 } else {
9 var result = {}
10 key = '' + key
11 for (var k in object) {
12 if (object.hasOwnProperty(k) && key !== k) {
13 result[k] = object[k]
14 }
15 }
16 return result
17 }
18}