Let’s assume you are using erb. A first approach:
<%= javascript_tag "account_ids = #{account_ids.to_json.html_safe};" %>
The problem is that this creates a global variable without context (who uses it?). That’s why I’d rather call a function defined somewhere in your JS code:
<%= javascript_tag "setAccounts(#{account_ids.to_json.html_safe});" %>