What is the impact of using too much of JS Object's delete method?

recently there are many delete methods used, which always feel strange. Apart from affecting the original array, is there any harm to delete?

let a = true;
let obj = {
  name: "xiaobi",
  age: 22
}
if(a === true) {
 delete obj.age
}
console.log(obj);

// {name: "xiaobi"}
May.18,2022

try not to use the delete keyword. Use Reflect.deleteProperty (object, key) to see the official usage of


delete doesn't really free memory, it just breaks the reference


  • if the property you are trying to delete does not exist, delete will not have any effect, but will still return true
  • if the object's prototype chain has an attribute with the same name as the property to be deleted, the object will use that property on the prototype chain after the property is deleted (that is, the delete operation will only work on its own properties)
  • any property declared with var cannot be removed from the global scope or from the scope of the function.
    in this case, the delete operation cannot delete any function in the global scope (whether the function comes from a function declaration or function expression)
    except that the function in the global scope cannot be deleted, the function in the object (object) can be deleted with the delete operation.
  • any property declared with let or const cannot be removed from the scope in which it is declared.
  • unsettable (Non-configurable) properties cannot be removed. This means that properties of built-in objects such as Math, Array, and Object and properties that cannot be set using the Object.defineProperty () method cannot be removed.

what are the problems with the delete operator? see this article


add a judgment to filter out the age attribute. Why delete? What are your needs? what do you want?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e9d0-2bc7e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e9d0-2bc7e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?