I'd rather not have to duplicate said function.
app/assets/javascripts/application.js
$(document).on('pagecontainershow', function() {
  function someOtherFunction() {
    console.log('Hello world')
  }
  
  // ...
});app/views/articles/create.js.erb
<% unless @article.errors.any? %>
  someOtherFunction();
<% end %>app/assets/javascripts/application.js
function someOtherFunction() {
  console.log('Hello world')
}
  
$(document).on('pagecontainershow', function() {
  // ...
});