Javascript examples for Object:Object Property
Implement the removeProperty function to take an object and a property name, delete the property
<html> <head></head> <body> <h1>JavaScript Functions</h1> <p onclick="removeProperty(obj,'name')">This example calls :</p> <script> function removeProperty(obj,prop){ if(obj.hasOwnProperty(prop)) {//from w ww . java 2 s . c om console.log(obj); var b = delete obj.prop; console.log(b); return true; } else { return false; } } var obj= { name:"John" }; removeProperty(obj,'name'); </script> </body> </html>