Playing around with JavaScript for Automation, I find myself not able to do something that is very simple in AppleScript. (Shocker, I know.)
This AppleScript:
tell application "Finder" to set selection to {}
clears the selection in Finder.
I just cannot figure out how to do the same in JXA.
Here's what I've tried:
var finder = Application("Finder")
finder.includeStandardAdditions = true
//this selects files in the front window...
finder.select( [...array of file paths...] )
//so you'd think this might work to deselect all...
finder.select( [] )
//...but it doesn't do anything
//then I tried each of these in turn...
finder.select( null )
//Error -10010: Handler can't handle objects of this class.
finder.selection = null
//Error -10010: Handler can't handle objects of this class.
finder.selection = []
//Script Editor crashes
//...but none were successful
Any suggestions?
(macOS Sierra, Script Editor 2.9)