Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

New Here ,
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, Server developers

Views

114

Likes

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

Adobe Community Professional , 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.

Likes

Translate

Translate
Adobe Community Professional ,
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.

 

Likes

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

Copy link to clipboard

Copied

LATEST

Thank you BarlaeDC.

Likes

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