3

Suppose you have an instance of an object, obj, and want to unset set a property called prop. What are the ultimate differences with the following two variants:

delete obj.prop;
obj.prop = undefined;

I believe that these both have the same meaning, but in the case of setting the property to undefined, the reference to the property does not have to be removed so a little work is saved. Correct me if I'm wrong.

  • 3
    *both have the same meaning* - Nope. In the first case, `prop` is **NOT** a property of `obj`, but in the second case, `prop` is a property of `obj` with value `undefined`. – thefourtheye Aug 27 '15 at 19:21
  • 2
    Typing the title of your question into Google brought me the duplicate. Maybe try that first. –  Aug 27 '15 at 19:23

0 Answers0