If GlideRecord
and so on are classes or constructor functions, you can use the constructor
property.
class GlideRecord {}
// or legacy constructor function -
// function GlideRecord() {}
const instance = new GlideRecord()
const { constructor } = instance
console.log(constructor) // GlideRecord
console.log(constructor.name) // "GlideRecord"
console.log(constructor === GlideRecord) // true
Note that this will not work if they're just plain old JS objects created with factory functions - in this case, constructor
will simply be Object
:
const createGlideRecord = () => {
return { /* ... */ }
}
const instance = createGlideRecord()
const { constructor } = instance
console.log(constructor) // Object
console.log(constructor.name) // "Object"
console.log(constructor === createGlideRecord) // false