Any tasks, projects or tags selected?

Not sure what its history is, but I’ve seen OmniFocus plugins by a couple of different contributors using this rather complex and slightly unexpected incantation:

var conditionsArray = [
      eval(selection.tasks.length > 0),
      eval(selection.projects.length > 0),
      eval(selection.tags.length > 0),
    return conditionsArray.includes(true);

and fortunately we don’t need to do this kind of thing at all,
because JS Arrays have a couple of very useful built-in methods
which do it all for us for free, and more safely:

  • .some()
  • .every()

So here, we could ease our task with expressions like:

].some(x => x.length > 0)

or if brevity, or the avoidance of repetition, are your preference, then perhaps:

["tasks", "projects", "tags"].some(
    k => selection[k].length > 0


A thousand voices from every direction continually (and quite stridently) warn us against ever using eval.

On the very rare occasions where something like it does seems to be inevitable, it’s usually better to look up the documentation of the Function constructor:

[Function - JavaScript | MDN](

1 Like

PS, for a little more detail on avoiding eval, see the relevant page of the inestimable ESLint, which, over the course of a year, can protect the hapless scripter from a huge amount of bafflement and wasted time:

[no-eval - ESLint]( )