1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-09 15:59:06 +01:00

problems(js): add “2618. Check if Object Instance of Class”

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2023-06-03 20:28:52 +02:00
parent 8a7ffff7d2
commit 86599c22a7
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,16 @@
/**
* @param {any} obj
* @param {any} classFunction
* @return {boolean}
*/
var checkIfInstanceOf = function(obj, classFunction) {
if (obj === null || obj === undefined || typeof classFunction !== "function") {
return false;
}
return Object(obj) instanceof classFunction;
};
/**
* checkIfInstanceOf(new Date(), Date); // true
*/