Question: How to remove a property of JavaScript object
Answer:
Javascript Object
let myObj = { "firstName": "Rustcode", "lastName": "Web", "fullName": "RustcodeWeb" };
First Method
delete myObj['fullName']; console.log(myObj);
Second Method
delete myObj.fullName; console.log(myObj);
Third Method
var fullNameRemove = "fullName"; delete myObj[fullNameRemove]; console.log(myObj);
Output:
{ firstName: "Rustcode", lastName: "Web" }
We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.
Comments
Post a Comment