2

I need to remove vegetables from this object

 "shop":
     {
     "items":
       {
          "fruits" : [],
         "vegetables" :[]
       }
    } 
  }

i tried deleting by "delete shop.items.fuits"... but it didnot work

Dinesh
  • 31
  • 1
  • 3
  • 2
    Possible duplicate of [How to remove nested attributes?](https://stackoverflow.com/questions/13234301/how-to-remove-nested-attributes) – Koby Douek Jun 18 '17 at 11:54
  • If the code in the question is correct you are missing quotes around the vegetable property. – DD84 Jun 18 '17 at 17:58

1 Answers1

1

It seems to be working...

const o = { a: { b: { c: [], d: 4 } } }
delete o.a.b.c

console.log(o)
.as-console-wrapper { max-height: 100% !important; top: 0; }
Diego
  • 816
  • 7
  • 17