0

I have this:

console.log(
   delete ({a: true}['a'])
);

that will log true. But so will this:

 console.log(
    delete ({a: true}['b'])
 );

I am just trying to use a one-liner to return whether a key was present in the object before it was deleted.

It looks like I have to do this instead?

  const v = {a: true};
  console.log(('b' in v) && delete v['b']);

why doesn't the delete operator return false if 'b' is not present in the object?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

0 Answers0