A JavaScript for Automation version:
Thank you, Rob.
Very interesting script thank you. I have been holding back on learning javascript for automation until somebody writes a book on it (well it would be my only reason for learning javascript too!). Right now I don’t think I could face jumping in the cold deep end !
Frederiko
The only real semantic differences are that:
- records introspect (they can list their keys for you),
- and functions are first class objects (you can pass them as arguments, convert them to strings etc)
Apart from that, built-in map and reduce are certainly a bit quicker to write and less prone to glitch than keeping track of mutating iterators in loops, and the built-in regex and other libraries generally do make things easier.
I like it.
Which editor are you using for JAX? It doesn’t seem that Script Debugger supports it yet.
Thanks for your code and comments. I am going to play around with it a bit.
Frederiko
Since OS X 10.11 it has been possible, from Script Editor, to use the (excellent) JavaScript debugger in Safari.
developer.apple.com/library/mac … -CH110-SW1
I switch into Script Editor whenever I want to use that debugger, but I spend most of the time using Github’s atom.io/ (broadly used, actively developed), with the two packages:
- atom.io/packages/script (for running .scpt scripts from inside Atom)
- atom.io/packages/language-javascript-jxa (for syntax highlighting etc)
Enjoy experimenting
Will definitely. Thanks for the help.
Frederiko
FWIW I have drafted a JavaScript for Automation binding for Pashua.