How To Remove a Custom Action At Web Level With JSOM in SharePoint

var ideaCtx = SP.ClientContext.get_current();
var web = ideaCtx.get_web();
var oCustomActions = web.get_userCustomActions();
ideaCtx.load(oCustomActions);
ideaCtx.executeQueryAsync(
function () {
    var enumerator = oCustomActions.getEnumerator();
    while (enumerator.moveNext()) {
        // first log all Custom Actions to identify the one you want to delete
        console.log(enumerator.get_current().get_title() + " -> " + enumerator.get_current().get_location());                
    }
    var ca = oCustomActions.getItemAtIndex(theRightIndex); // choose this after 
    //console.log(ca);
    ca.deleteObject()
    ideaCtx.executeQueryAsync(
    function () { console.log('CA deleted successfully'); },
    function (sender, args) { console.log(args.get_message()); }
    )
},
function (sender, args) { console.log(args.get_message()); });