• Category

    Get a string name for a class method.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • ctor: (new (...args) => any)

      The class to use as the first part of the name

        • new (...args): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • method: AnyFunction

      The method to use as the second part of the name

    Returns `${string}${"." | "#"}${string}`

    A string name for the method

    Object

    Example

    class Class {
    static staticMethod() {}
    }

    name(Class, Class.staticMethod); // 'Class.staticMethod'

    Example

    class Class {
    instanceMethod() {}
    }

    name(Class, Class.prototype.instanceMethod); // 'Class#instanceMethod'
  • Category

    Get the name of a function or class.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • func: AnyFunction | (new (...args) => any)

      The function or class to get the name for

    Returns string

    The name of func

    Object

    Example

    function func() {}

    name(func); // 'func'

    Example

    class Class {}

    name(Class); // 'Class'