const obj = {
name: undefined,
age: 15,
school: 'Some school'
}
const size = x => x.length;
const keys = x => Object.keys(x);
const every = (x, y) => y.every(x);
const includes = x => y => x.includes(y);
const hasOnlyDirect = (obj,props) => {
var objProps = Object.keys(obj)
return objProps.length == props.length && props.every(p => objProps.includes(p))
};
const hasOnlyFn = (obj,props) => {
const objProps = keys(obj)
return size(objProps) == size(props) && every(includes(objProps), props);
};
hasOnlyDirect(obj,['name','age']) //return false
hasOnlyDirect(obj,['name','age','city']) //return false
hasOnlyDirect(obj,['name','age','school']) //return true
hasOnlyFn(obj,['name','age']) //return false
hasOnlyFn(obj,['name','age','city']) //return false
hasOnlyFn(obj,['name','age','school']) //return true