how to remove a property from a javascript object for example : a ={ “name”:”kuldeep”,age:33,height:170} , remove height from this object
Kuldeep Baberwal Changed status to publish October 16, 2023
You can remove a property from a JavaScript object using the delete keyword. In your example, you want to remove the property height from the object a. Here’s how you can do it:
var a = { “name”: “kuldeep”, age: 33, height: 170 };
// Remove the ‘height’ property
delete a.height;
console.log(a);
After running this code, the object a
will be modified, and it will now look like this:
{ “name”: “kuldeep”, age: 33 }
Kuldeep Baberwal Changed status to publish October 16, 2023