Check if user has specific permission

I am using SharePoint server 2016. I want to check if logged in user has specific permission or user lies into specific permission group. So I trying to fetch using EffectiveBasePermissions.


var context = null;       var web = null; context = new SP.ClientContext.get_current();           web = context.get_web();   var perm = web.get_effectiveBasePermissions();   alert(perm.has(SP.PermissionKind.approveItems));   context.load(web);          context.executeQueryAsync(onSuccessMethod, onFaiureMethodl);  function onSuccessMethod(sender, args) {           var userObject = web.get_currentUser();                   alert('User name:' + userObject.get_title() + '\n Login Name:' + userObject.get_loginName());     }       function onFaiureMethodl(sender, args) {         alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());       } 

But I am getting error as:

The property or field ‘EffectiveBasePermissions’ has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

Is there any better way to achieve same?