The ‘DELETE’ keyword in JavaScript
Video
JavaScript Notes
JavaScript
// delete.js
// How to remove properties from Objects
let log = console.log;
let obj = {
prop1: 42,
prop2: 'Meaning of life',
prop3: function( ) { }
};
delete obj.prop3 ; // deletes prop3 from object, obj
log(obj.prop1, obj.prop2, obj.prop3, obj.prop4); // if a property doesn’t exist, undefined is returned
Feedback
Submit and view feedback