import { hasOwnMethod } from "https://deno.land/x/ayonli_jsext@v0.9.72/object/index.ts";
Returns true
if the specified object has the indicated method as its own method (in its own
prototype). If the method is inherited, or is not in the prototype, or does not exist, this
function returns false
.
Examples
Example 1
Example 1
import { hasOwnMethod } from "@ayonli/jsext/object";
class MyClass {
foo() {
return "Hello";
}
bar = () => "World";
}
const obj = new MyClass();
console.log(hasOwnMethod(obj, "foo")); // true
console.log(hasOwnMethod(obj, "bar")); // false
console.log(hasOwnMethod(obj, "toString")); // false