Copy link to clipboard
Copied
Hello All,
Can someone explain how object equality works in the Premiere Pro?
I am bit confused with following two different outcome
app.project == app.project // returns true
app.projects[0] == app.projects[0] // returns false
Why it behaves differently with same type of object?
Premiere Pro Version: 12.0.0
Extension Type: Panel
Thanks & Regards,
Meet Tank
Hi Meet,
I guess it's because they're fundamentally different. For the lack of better knowledge iI would assume it works like this:
app.project = an object with a set of properties and methods, so if you compare two of those their properties and methods are being checked for equality.
app.projects = an array of "some references". When compared, there is no drilldown (recursion) to check if the reference is identical, it's just "some reference".
So you would always need to check for a specific proper
...Copy link to clipboard
Copied
Hi Meet,
I guess it's because they're fundamentally different. For the lack of better knowledge iI would assume it works like this:
app.project = an object with a set of properties and methods, so if you compare two of those their properties and methods are being checked for equality.
app.projects = an array of "some references". When compared, there is no drilldown (recursion) to check if the reference is identical, it's just "some reference".
So you would always need to check for a specific property (like documentID) to check for equality.
if (app.project.documentID === app.project.documentID) {
$.writeln ("Project equal");
} else {
$.writeln ("Project NOT equal");
}
if (app.projects[0].documentID === app.project.documentID) {
$.writeln ("Project equal");
} else {
$.writeln ("Project NOT equal");
}
if (app.projects[0].documentID === app.projects[0].documentID) {
$.writeln ("Project equal");
} else {
$.writeln ("Project NOT equal");
}
Best,
Erik