In Javascript, you can delete an object property:
var o = { x: 1, y: 2 }; var wasDeleted = delete ox;
Now ox should be undefined and wasDeleted equal to true .
However, you can only delete your own objects, and, unfortunately, browsers have different ideas about this:
window.x = 1; delete window.x;
Now in Chrome and IE9-10 x will be undefined , but in IE6-8 this throws an exception:
"Object does not support this action"
Great. Please note that this does not mean that delete not supported ...
// Oops, no var, so this is now a global, should've 'use strict' o = { x: 1, y: 2 }; // Works delete ox; // Works delete window.oy; // Fails, but only in IE6-8 :-( delete window.o
I understand that I can add a try {...} catch , but ...
Is there a way to check if the browser supports delete specific object before calling it?
those. can I tell if the property is considered by the browser to be a host or native?