• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How object equality works in Extendscript?

Participant ,
Nov 30, 2017 Nov 30, 2017

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

TOPICS
SDK

Views

372

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Dec 01, 2017 Dec 01, 2017

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

...

Votes

Translate

Translate
Engaged ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines