Why use typeof for identifying a function?

后端 未结 6 592
天涯浪人
天涯浪人 2020-12-09 13:03

Are there any significant reasons for using

typeof variable === \'function\'

versus

!!variable.call

for d

6条回答
  •  时光说笑
    2020-12-09 13:34

    typeof variable === 'function' is better than !!variable.call because if variable is undefined or null, !!variable.call will throw an error.

提交回复
热议问题