问题描述
使用脚本编辑器使用新的 JS 实现自动化.我在以下最后一行收到错误:
Playing with the new JS for automation using Script Editor. I'm getting an error on the final line of the following:
var iTunes = Application("iTunes");
var sources = iTunes.sources();
var library = sources.whose({name : "Library"});
确认源数组符合预期(两个元素,一个带有 name
Library",一个带有Internet Radio").但是最后一行被 Error on line 3: TypeError: undefined is not a function (evaluating 'sources.whose({name : "Library"})')
阻塞了.
Confirmed that the sources array is as expected (two elements, one with name
"Library" and one "Internet Radio"). But that final line chokes with Error on line 3: TypeError: undefined is not a function (evaluating 'sources.whose({name : "Library"})')
.
据我所知,我是 为whose
函数 使用正确的语法.(我也尝试使用显式 _equals
子句来达到相同的结果.)我做错了什么?
As far as I can tell, I'm using the right syntax for the whose
function. (I also tried with an explicit _equals
clause to the same result.) What am I doing wrong?
推荐答案
这现在就像理论预测的那样工作.
This now works as theory would predict.
(function () {
'use strict';
var iTunes = Application('iTunes'),
filtered = iTunes.sources.whose({
name: 'Library'
});
return filtered().length;
})();
这篇关于使用“谁的"用于自动化的 Javascript 中的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!