Remove JavaScript Object Property
For this example, we have created an object with some default values.1 2 3 4 5 | var obj = { "webid": "101", "webname": "TecAdmin", "regex": "^https://.*" }; |
Now, use delete operator to delete the specific property from the JavaScript object.
1 | delete obj.regex; |
Similarily, you can also use following syntax to with delete operator.
1 | delete obj['regex']; |
Example:
Below is an working example of removing a property from java script object. Add below content in a HTML file and access in web browser. Now open console in browser to view the results.1 2 3 4 5 6 7 8 9 10 11 12 | var obj = { "webid": "101", "webname": "TecAdmin" "regex": "^https://.*" }; console.log('-- Object data before remove --'); console.log(obj); delete obj.regex; console.log('-- Object data after remove --'); console.log(obj); |

Comments
Post a Comment