36

I presume this is an odd question but I have to ask..

If I have a js object that looks like this:

$scope.obj1 = {
    "name":"John",
    "number":"Eleven",
    "color":"Red"
}

Is there a way to remove an entire property? without re-assigning values to a new object.. So if I want to get rid of "number":"Eleven", I would like the object to look like this...

$scope.obj1 = {
    "name":"John",
    "color":"Red"
}

Thanks!

JAAulde
  • 19,250
  • 5
  • 52
  • 63
GRowing
  • 4,629
  • 13
  • 52
  • 75
  • 1
    *"If I have a json object [...]"* [There is no such thing as a "JSON object"](http://benalman.com/news/2010/03/theres-no-such-thing-as-a-json/). – Felix Kling May 12 '14 at 22:09
  • I am aware of that... I wrote this small tidbit as a string to ask a question... thanks anyways. – GRowing May 12 '14 at 23:23

1 Answers1

11

JavaScript has a delete operator:

delete $scope.obj1.number
zzzzBov
  • 174,988
  • 54
  • 320
  • 367