Can I use Javascript to write a custom function for Numbers? It's always annoyed me that I can't write a custom function for Numbers. It would make the spreadsheet so much more useful to me.  In Google Apps spreadsheets you can do it, using Javascript.  

In other words, you write

function myCustomStuff(a, b) { ... }


and a cell can contain:

=myCustomStuff(A1, B2)


Now, in Yosemite, they have Javascript automation. I wonder if it's possible.
No - injecting a function looks to be something that isn't easily scriptable.

A simple macro might be doable and you could start with these two references:


https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html


This link is the developer documentation on how to connect the script to the Numbers app.


https://iworkautomation.com/numbers/cell.html


This automation site has for a very long time been the best place I've known to learn and implement AppleScript tools. 

If you're new, you could follow the numbers tutorial in AppleScript to make sure  you have a workable task and then re-code it in the new language. Then you'd need to determine the hooks in Numbers and see if your specific task is doable without utilizing the Objective-C bridge which allows lower level integration to apps on OS X.