Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/object/index.ts>hasOwnMethod

A JavaScript extension package for building strong and modern applications.
Latest
function hasOwnMethod
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

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

Parameters

obj: any
method: string | symbol

Returns

boolean