I have an on object like so
var obj = {};
function set()
{
obj.x1 = 20;
obj.y1 = 35;
obj.x2 = 60;
obj.y2 = 55;
...
}
开发者_如何学GoWhats the quickest way to delete/reset all of the properties of obj?
for (p in obj) {
if (obj.hasOwnProperty(p)) {
delete obj[p];
}
}
If you only have one reference to the object, then replacing it with a new one would be faster.
obj = {};
精彩评论