-
Check for an invalid Object
Is there a best practice to check if an object is invalid without halting execution?
var c = app.project.activeItem;Using try/catch is the only way I have found to work:
var a = c.layer(1); // "[object AVLayer]"
a.remove(); // Object is invalid
//Trying to access a property known not to exist:
a.name // "Unable to execute script at line 1."
try { a.name } catch (err) {
alert("ReferenceError ignored");
// ...
}