Continuing the discussion from How to Create JavaScript Multiline String Literals (Template Literals):
NOTE: I'm sure I'll get some terms wrong here, or at least not explicit enough, so I may come back and edit some of this, once my mistakes have been pointed out.
##The Issue:
One of the issues when working with JavaScript for Automation (JXA), is determining what features are available on which version of OS/X. And really, it's not which version of OS/X - it's which version of Safari and its supporting libraries (hereafter referred to collectively as "Safari") are installed.
##Example: Can I use "String.endsWith()"?
I think developer.mozilla.org is the place to go for this information. I would do a google search for:
javascript String.endsWith() mdn
("mdn" means Mozilla Developer Network), and I would end up at this page:
The first thing I do is go to the bottom of the page, to find this grid:
It says Safari supports String.endsWith() starting in version 9, which is generally OS/X 10.10 (add one to the Safari number).
So now we know that if we want to use String.endsWith(), it means if people are still on Yosemite, they can't use our script.
Or does it?
##Enter "Polyfill"
There's a really cool concept called "Polyfill". It's a way to add a prototype definition for a feature, in such a way as to add it only if it isn't already supported.
Back to the Mozilla page again. Somewhere on the page, you'll find something like this:
Just copy and paste that code at the top of you JXA script, and you can safely use String.endsWith() in your script, even on Yosemite.
##Conclusion
Only you can decide which features to use or not use. But in general, if you ever intend on sharing your script, you should always check MDN to see a particular feature is available or not.