Pristine icon indicating copy to clipboard operation
Pristine copied to clipboard

isFunction helper

Open DimaGashko opened this issue 5 years ago • 3 comments

Why do you use this helper?

export function isFunction(obj) {
    return !!(obj && obj.constructor && obj.call && obj.apply);
}

Why not just typeof func === 'function'?

DimaGashko avatar Jan 27 '20 10:01 DimaGashko

typeof Object, typeof Date, and typeof String, etc all return 'function'

sha256 avatar Aug 18 '20 05:08 sha256

Yes, them do... but that's because all of them are functions. And that's why ever the isFunction helper also says that them are functions

function isFunction(obj) {
    return !!(obj && obj.constructor && obj.call && obj.apply);
}
undefined
isFunction(Object)
true
isFunction(String)
true
isFunction(Date)
true

image

DimaGashko avatar Aug 26 '20 07:08 DimaGashko

Hi @psmyrdek, could you please have a look since this function was added by you? :)

sha256 avatar Aug 26 '20 14:08 sha256