The module josm/ui/menu provides the class JSAction which can be used to create actions and add them to the JOSM menu and/or the JOSM toolbar.
var JSAction = require("josm/ui/menu").JSAction; // create the action var action = new JSAction({ name: "My Action", tooltip: "This is my action", onExecute: function() { josm.alert("MyAction: executing ..."); } }); // add it to the edit menu action.addToMenu(josm.menu.get("edit")); // add it to the toolbar (append it at the end of the toolbar) action.addToToolbar({at: "end"});