[英]Javascript/InDesign: Check if Object has certain property
我正在使用Javascript进行InDesign脚本编写。
我有一个图像对象,想知道它的边界(用户看到的那个) -
bounds = (geometricBounds in image.parent)? image.parent.geometricBounds: image.geometricBounds;
返回ReferenceError - geometricBounds is undefined
。 当图像的父级是Oval对象时,会出现此错误(因此,我知道geometryBounds属性适用于Oval对象)。
问题在于(geometricBounds in image.parent)
因为当我提醒这个语句时,我得到了同样的错误。 我肯定错过了一些东西 - 因为如果这不是一个属性那么我应该只是弄错了。
任何人都知道为什么会这样吗?
in
运算符检查属性名称是否为字符串(在您的情况下,它正在查找名为geometricBounds
的变量 - 可能包含属性名称字符串 - 显然未在任何地方声明):
bounds = ('geometricBounds' in image.parent)? image.parent.geometricBounds: image.geometricBounds;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.