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

Could you please check what is the difference between both the snippet?

Explorer ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

Dear Member,

 

Could you please check what is the difference between both the snippet? 

First one is giving wrong output.

 

Sumit

 

                parentPage = (prevPageItem && prevPageItem.parentPage.documentOffset >= element.getParentPage().documentOffset) ?
                    prevPageItem.parentPage :
                    (element.getParentPage().documentOffset > firstPage.documentOffset) ?
                        element.getParentPage() :
                        document.pages.item(parentPage.documentOffset + 1);

 

parentPage = (function () {
                    if (prevPageItem && prevPageItem.parentPage.documentOffset >= element.getParentPage().documentOffset)
                        return prevPageItem.parentPage;
                    else if ((elementParentPage = element.getParentPage()).documentOffset > firstPage.documentOffset)
                        return elementParentPage;
                    else return document.pages.item(firstPage.documentOffset + 1);
                }).call();

VS 

TOPICS
Performance , Scripting , SDK

Views

226

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

Community Expert , Mar 23, 2021 Mar 23, 2021

Hi,

I am not sure what is different but I would guide against using nested ternary methods as this makes the code harder to follow, therefore I would always recommend that you use the second option, in terms of coding style.

 

Votes

Translate

Translate
Community Expert ,
Mar 23, 2021 Mar 23, 2021

Copy link to clipboard

Copied

Hi,

I am not sure what is different but I would guide against using nested ternary methods as this makes the code harder to follow, therefore I would always recommend that you use the second option, in terms of coding style.

 

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
Explorer ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

LATEST

Thank you BarlaeDC.

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