Skip to main content
dublove
Legend
October 2, 2025
解決済み

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

  • October 2, 2025
  • 返信数 5.
  • 203 ビュー

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.

解決に役立った回答 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
}

返信数 5

dublove
dublove作成者
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
dublove作成者
Legend
October 3, 2025

Hi @Manan Joshi 

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