How to delete SP.Group in SharePoint 2013 via JSOM
Use SP.GroupCollection.remove, SP.GroupCollection.removeById or SP.GroupCollection.removeByLoginName methods to remove Group from site.
Example
var context = SP.ClientContext.get_current();
var groups = context.get_web().get_siteGroups();
groups.removeById(groupId);
context.executeQueryAsync(
function() {
console.log('Group is deleted');
},
function(sender, args) {
console.log(args.get_message());
}
);
In your case it is not clear why you need to remove all the groups where user belongs to, but the following script demonstrates how to perform that:
var context = SP.ClientContext.get_current();
var user = context.get_web().getUserById(userId);
context.load(user,'Groups');
context.executeQueryAsync(
function() {
var groups = user.get_groups();
for(var i = 0; i < groups.get_count();i++) {
var group = groups.getItemAtIndex(i);
groups.removeByLoginName(group.get_loginName());
}
context.executeQueryAsync(
function() {
console.log('Completed');
},
function(sender, args) {
console.log(args.get_message());
}
);
},
function(sender, args) {
console.log(args.get_message());
}
);