Skip to main content
dublove
Legend
October 2, 2025
Answered

Is there a way to determine if all four values of insetSpacing are 0?

  • October 2, 2025
  • 1 reply
  • 187 views

Like this:

If all four values are 0, I modify it.

Otherwise, if the first value is greater than 0, I don't modify it.

Correct answer m1b

@dublove Exactly as @Manan Joshi rightly said a better way is to be direct, not hidden type coercion:

if (
    textFramePreferences.insetSpacing[0] === 0
    && textFramePreferences.insetSpacing[1] === 0
    && textFramePreferences.insetSpacing[2] === 0
    && textFramePreferences.insetSpacing[3] === 0
) {
    // do something
}

1 reply

dublove
dubloveAuthor
Legend
October 2, 2025

Got it, thanks.
if(textFramePreferences.insetSpacing == “0,0,0,0”)

Community Expert
October 3, 2025

This works but you should understand what it is doing and this may not be the best way to do such comparisons. Here the array is being converted into a string and then compared to the other string constant that you have. The conversion is done automatically for you. A better and more reliable way in generic terms would be to explicitly match all the index values.

-Manan

-Manan
dublove
dubloveAuthor
Legend
October 3, 2025

Hi @Manan Joshi 

For example, I want to determine whether the top margin value is 2.
Is this possible?