You might use _.intersection
and Object.keys
:
function yourFunc(args) {
if(_.intersection(["name", "secondName", "age"], Object.keys(args)).length != 3) {
throw Error("Check your arguments: something is missing!");
}
}
Note that this kind of check will work if arguments aren't instantited from a prototype. From Mozilla Development network:
The Object.keys() method returns an array of a given object's own enumerable properties, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).