Skip to main content
dublove
Legend
Oct 2, 2025 11:35 AM UTC
Answered

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

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
m1bCorrect answer
Community Expert
Oct 3, 2025 8:40 AM UTC

@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 replies

dublove
dubloveAuthor
Legend
Oct 2, 2025 11:42 AM UTC

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

Translate
Community Expert
Oct 3, 2025 2:27 AM UTC

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

Translate
-Manan
dublove
dubloveAuthor
Legend
Oct 3, 2025 2:46 AM UTC

Hi @Manan Joshi 

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

Translate