illustrator javascript/extendscript 中的 Min Max 函数错误?
有人可以解释为什么以下代码在 Safari/Javascript 和 Illustrator/ExtendScript 中返回不同的结果吗?
在我的测试中,浏览器版本似乎按预期工作。插画师没那么多。这是一个真正的错误吗?或者只是 ExtendScript(Adobe 针对 Creative Suite 应用程序的 Javascript 实现)和 apply 方法的问题?
function testMinMax(){
var testArray = [2,1,7,3,6,7,8,23,45,26,13,9];
function getMinOfArray(numArray) {
return Math.min.apply(Math, numArray);
}
function getMaxOfArray(numArray) {
return Math.max.apply(Math, numArray);
}
alert ("min [" + getMinOfArray(testArray) + "] of " + testArray);
alert ("max [" + getMaxOfArray(testArray) + "] of " + testArray);
// Expected Values:
// min [1] of 2,1,7,3,6,7,8,23,45,26,13,9
// max [45] of 2,1,7,3,6,7,8,23,45,26,13,9
// Illustrator Scripting returns the following values
// min [1] of 2,1,7,3,6,7,8,23,45,26,13,9
// max [9] of 2,1,7,3,6,7,8,23,45,26,13,9
}
// Call the test case
testMinMax();
Can someone explain why the following code returns different results in Safari/Javascript and Illustrator/ExtendScript?
In my tests the browser version of this seems to work as expected. Illustrator not so much. Is this a genuine bug? Or just an issue with ExtendScript (Adobe's Javascript implementation for Creative Suite apps) and the apply method?
function testMinMax(){
var testArray = [2,1,7,3,6,7,8,23,45,26,13,9];
function getMinOfArray(numArray) {
return Math.min.apply(Math, numArray);
}
function getMaxOfArray(numArray) {
return Math.max.apply(Math, numArray);
}
alert ("min [" + getMinOfArray(testArray) + "] of " + testArray);
alert ("max [" + getMaxOfArray(testArray) + "] of " + testArray);
// Expected Values:
// min [1] of 2,1,7,3,6,7,8,23,45,26,13,9
// max [45] of 2,1,7,3,6,7,8,23,45,26,13,9
// Illustrator Scripting returns the following values
// min [1] of 2,1,7,3,6,7,8,23,45,26,13,9
// max [9] of 2,1,7,3,6,7,8,23,45,26,13,9
}
// Call the test case
testMinMax();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有类似的问题。在我看到你的帖子(我唯一能找到的)后,我不得不想出这个解决方法;
I had a similar problem. After I saw your post (the only thing I could find), I had to come up with this workaround;