Function: objectConstructor()
objectConstructor<
objectPrototype>(target):IConstructor<objectPrototype>
Get the class an object was created by: its constructor property, as inherited from its prototype.
Type Parameters
objectPrototype
objectPrototype extends Object
Parameters
target
objectPrototype
An object (a class instance, a plain object, an array). Its constructor property is read as is: an object which overrides it gives that value, and an object without prototype (Object.create(null)) gives undefined despite the return type.
Returns
IConstructor<objectPrototype>
The constructor: the class for an instance, Object for a plain object.
Example
typescript
import {objectConstructor} from 'lakutata/utils'
class User {
}
console.log(objectConstructor(new User()) === User, objectConstructor({}) === Object)
//true true