I’m assuming this js in running in the browser (rather than server side) - if so then you would need to just use keyword formatting by itself to get the desired result, as the keywords are evaluated by matrix then returned to the browser where the JS is executed.
If the value 12345 was in a query parameter in the URL called ‘x’ (http://domain.com?x=12345) then could use something like:
If you want to do it from js running in the browser, you would need to make a call back to the server…
Eg: you could have an asset thats sole purpose was to get an id via a query parameter, convert the keyword and output the asset name.
A simple implementation would be a standard page with a design/layout setup to just return plain text - its content would be:
%globals_get_x^as_asset:asset_name%
Then use an ajax call to send the id to it eg if using jquery:
$.get("http://site.com/yourpage?x=12345",function(data) {
// use the page name that is returned in the 'data' parameter
});
There are other ways that you could go about this, but it would depend on the specifics of your js application - eg in some cases you might pre generate data and load it with the page, or you might look into using the JS api for more complex needs.